//
//  NewCarInformationViewController.m
//  HondaPro_2
//
//  Created by ht on 13-8-21.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "NewCarInformationViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "webConfig.h"
#import "webService.h"
#import "HelpClass.h"
#import "SVProgressHUD.h"
#import "MyAFNetWorkManager.h"
#import "MJRefresh.h"
@interface NewCarInformationViewController ()


{
    BOOL flag;
    NSInteger from;
    NSInteger to;

}

@property(nonatomic,strong)NSMutableDictionary * queryDic;
@end

@implementation NewCarInformationViewController
{
    BOOL _warrantyChoose;
    BOOL _TypeXy;
    BOOL _TypePt;
}
@synthesize subNewTableView = _subNewTableView;

@synthesize carframe = _carframe;                       //车架号
@synthesize manufacturer = _manufacturer;               //生产厂家
@synthesize licenseplate = _licenseplate;               //车牌号
@synthesize model = _model;                             //型号
@synthesize engineField = _engineField;               //发动机号
@synthesize transmissionField = _transmissionField;   //变速箱号
@synthesize Inparagraph = _Inparagraph;                 //年款
@synthesize exhaust = _exhaust;                         //排气量
@synthesize transmissionType = _transmissionType;       //变速箱类型

@synthesize insideColor = _insideColor;              //内装颜色
@synthesize carClolr = _carClolr;                    //车辆颜色
@synthesize keyNumber = _keyNumber;                  //钥匙号
@synthesize countriesCodeName = _countriesCodeName;  //国家代码
@synthesize carUse = _carUse;                        //车辆用途
@synthesize warrantyNumber = _warrantyNumber;        //保修序号
@synthesize monthsOfNumber = _monthsOfNumber;        //保修月数

@synthesize insuranceCompany = _insuranceCompany;    //保险公司
@synthesize PurchaseDate = _PurchaseDate;            //保险购买日期
@synthesize DueDate = _DueDate;                      //保险到期日期
@synthesize checkStartDate = _checkStartDate;        //年度检查开始日期
@synthesize buyDate = _buyDate;                      //购买日期
@synthesize registrationDate = _registrationDate;    //上牌日期
@synthesize firstTimeDate = _firstTimeDate;          //第一次来厂日期
@synthesize lastComingMileage = _lastComingMileage;                    //最后一次来场里程

@synthesize backgroundView  = _backgroundView;
@synthesize carMasterButton = _carMasterButton;
@synthesize saveButton = _saveButton;
@synthesize WarrantyOptions = _WarrantyOptions;      //是否保修车辆选择框

@synthesize baoXiuDaoQi = _baoXiuDaoQi;
@synthesize layerLabel = _layerLabel;
@synthesize baoXiuDaoQiRi = _baoXiuDaoQiRi;
@synthesize baoXiuLiChen = _baoXiuLiChen;
@synthesize liChenShuRu = _liChenShuRu;
@synthesize keHuPopView = _keHuPopView;

//*弹出框内容
@synthesize queryTableView = _queryTableView;
@synthesize queryNumberField = _queryNumberField;
@synthesize queryNameField = _queryNameField;
@synthesize queryButton = _queryButton;
//数据字典
@synthesize carModifyDataDit = _carModifyDataDit;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    //初始化from-to
    from = 1;
    to = 10;
   
    
    self.carColorArray = [[NSMutableArray alloc]init];
    self.carInerColorArray = [[NSMutableArray alloc]init];
    self.carTypeArray = [[NSMutableArray alloc]init];
    self.chexiArr = [[NSMutableArray alloc]init];
    self.baoxiangongsiArray = [[NSMutableArray alloc]init];
    self.carUseArray = [[NSMutableArray alloc]init];
    [self addNotification];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.backgroundView = [[UIView alloc]initWithFrame:CGRectMake(70, 60, 1024-70-70, 768-55)];
    [self.backgroundView setBackgroundColor:[UIColor whiteColor]];
    [self.view addSubview:self.backgroundView];
    
//    self.subNewTableView = [[UITableView alloc]initWithFrame:CGRectMake(100, 575-44-44-20, 783, 120) style:UITableViewStylePlain];
//    [self.subNewTableView setScrollEnabled:NO];
//    [self.subNewTableView setDataSource:self];
//    [self.subNewTableView setDelegate:self];
//    [self.backgroundView addSubview:self.subNewTableView];
    
    [self loadSubView];
    
    [self loadfixedPicture];
    [self loadbuttonPictuerTwo];
    [self Avarietyoftextfield];
    [self loadbuttonPictuer];
    
   
    
    //通用代码表的字典
//    self.dicTmp = [HelpClass returnTheDataByJsonFileAndJustForTestWithFileName:@"codeA" andType:@"json"];
//    self.CarModifyDataArray = [[NSMutableArray alloc]initWithCapacity:10];
//    NSMutableDictionary *dic1 = [[NSMutableDictionary alloc]init];
//    NSMutableDictionary *dic2 = [[NSMutableDictionary alloc]init];
//    NSMutableDictionary *dic3 = [[NSMutableDictionary alloc]init];
//    [self.CarModifyDataArray addObject:dic1];
//    [self.CarModifyDataArray addObject:dic2];
//    [self.CarModifyDataArray addObject:dic3];
    
    //注册键盘即将消失的消息
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardHide:)
                                                 name:UIKeyboardDidHideNotification
                                               object:nil];
    
    _TypeXy = NO;
    _TypePt = YES;
    
    //存储queryTableView上的数据
    self.queryDataArray = [[NSMutableArray alloc]init];
    if ([_CLFlag isEqualToString:@"cl"]) {
        [self bjUI];
    }
}
#pragma mark--------------编辑UI
-(void)bjUI{
    NSLog(@"111111");
    self.carframe.text = _cjhStr;
    self.licenseplate.text = _cphStr;
    self.engineField.text = _fdjhStr;
    self.transmissionField.text = _bsxhStr;
    self.Inparagraph.text = _nkStr;
    self.exhaust.text =_pqlStr;
    self.remark.text  = _bzStr;
    self.keyNumber.text = _yshStr;
    self.lastComingMileage.text = _zhyclclcStr;
//    button
//    self.model xh
//    self.insideColor nzys
    [self.carClolr setTitle:_ClysStr forState:UIControlStateNormal];
    [self.model setTitle:_xhStr forState:UIControlStateNormal];
    [self.chexiBtn setTitle:_cxStr forState:UIControlStateNormal];
    [self.insideColor setTitle:_nzysStr forState:UIControlStateNormal];
    [self.carUse setTitle:_clytStr forState:UIControlStateNormal];
    [self.baoxiangongsiBtn setTitle:_bxgsStr forState:UIControlStateNormal];
    [self.baoxiangoumaiBtn setTitle:_bxgmrqStr forState:UIControlStateNormal];
    [self.baoxiandaoqiBtn setTitle:_bxdqrqStr forState:UIControlStateNormal];
    [self.buyDate setTitle:_gmrqStr forState:UIControlStateNormal];
    [self.registrationDate setTitle:_sprqStr forState:UIControlStateNormal];
    [self.firstTimeDate setTitle:_dyclcrqStr forState:UIControlStateNormal];
    
    
     //   为请求中的个别字段赋值   self.carColorId
    
//    self.CarUseID
    NSArray *zidianArr=[self readershuDICimform][@"VEHICLE_PURPOSE"];
    for(NSDictionary *dic in zidianArr)
    {
        if ([dic[@"NAME"] isEqualToString:_clytStr]) {
            self.CarUseID = dic[@"CODE"];
        }
    }
    
//     self.carTypeId
    NSArray *zidianArr1=[self readershuDICimform][@"MODEL"];
    for(NSDictionary *dic in zidianArr1)
    {
        if ([dic[@"MODEL_NAME"] isEqualToString:_xhStr]) {
            self.carTypeId = dic[@"MODEL_CODE"];
        }
    }
    //车系
    NSArray * chexiArr = [self readershuDICimform][@"SERIES"];
    for(NSDictionary *dic in chexiArr)
    {
        if ([dic[@"SERIES_NAME"] isEqualToString:_cxStr]) {
            self.chexiStr = dic[@"SERIES_CODE"];
        }
    }
    
//    self.baoxiangongsiID
    NSArray *zidianArr2=[self readershuDICimform][@"TM_INSURANCE"];
    for(NSDictionary *dic in zidianArr2)
    {
        if ([dic[@"NAME"] isEqualToString:_bxgsStr]) {
            self.baoxiangongsiID = dic[@"CODE"];
        }
    }
//    self.carColorId OUTER_COLOR
    NSArray *zidianArr3=[self readershuDICimform][@"OUTER_COLOR"];
    for(NSDictionary *dic in zidianArr3)
    {
        if ([dic[@"COLOR_NAME"] isEqualToString:_ClysStr]) {
            self.carColorId = dic[@"COLOR_CODE"];
        }
    }
    
    NSArray *zidianArr4=[self readershuDICimform][@"INNER_COLOR"];
    for(NSDictionary *dic in zidianArr4)
    {
        if ([dic[@"COLOR_NAME"] isEqualToString:_nzysStr]) {
            self.carInerColorId = dic[@"COLOR_CODE"];
        }
    }
}

#pragma 创建subView
-(void)loadSubView{
    
    UIView *subView = [[UIView alloc]initWithFrame:CGRectMake(100, 575-44-44, 783, 40)];
    subView.backgroundColor = [UIColor clearColor];
    [self.backgroundView addSubview:subView];
//    客户编号
    self.KHBHLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 110, 40)];
    self.KHBHLabel.backgroundColor = [UIColor clearColor];
    self.KHBHLabel.textColor = [UIColor grayColor];
    self.KHBHLabel.font =[UIFont fontWithName:@"ArialMT" size:14];
    self.KHBHLabel.textAlignment = NSTextAlignmentCenter;
    self.KHBHLabel.lineBreakMode = NSLineBreakByWordWrapping;
    self.KHBHLabel.numberOfLines = 0;
    self.KHBHLabel.text = _khbhStr;
    [subView addSubview:self.KHBHLabel];
//    客户名称
    self.KHMCLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.KHBHLabel.frame), 0, 110, 40)];
//    self.KHMCLabel.backgroundColor = [UIColor yellowColor];
    self.KHMCLabel.backgroundColor = [UIColor clearColor];
    self.KHMCLabel.textColor = [UIColor grayColor];
    self.KHMCLabel.font =[UIFont fontWithName:@"ArialMT" size:14];
    self.KHMCLabel.textAlignment = NSTextAlignmentCenter;
    self.KHMCLabel.lineBreakMode = NSLineBreakByWordWrapping;
    self.KHMCLabel.numberOfLines = 0;
    self.KHMCLabel.text = _khmcStr;
    [subView addSubview:self.KHMCLabel];
    
//    客户性质
    self.KHXZLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.KHMCLabel.frame), 0, 110, 40)];
   // self.KHXZLabel.backgroundColor = [UIColor whiteColor];
    self.KHXZLabel.backgroundColor = [UIColor clearColor];
    self.KHXZLabel.textColor = [UIColor grayColor];
    self.KHXZLabel.font =[UIFont fontWithName:@"ArialMT" size:14];
    self.KHXZLabel.textAlignment = NSTextAlignmentCenter;
    self.KHXZLabel.lineBreakMode = NSLineBreakByWordWrapping;
    self.KHXZLabel.numberOfLines = 0;
    self.KHXZLabel.text = _khxzStr;
    [subView addSubview:self.KHXZLabel];
    
//    手机
    self.SJLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.KHXZLabel.frame), 0, 110, 40)];
  //  self.SJLabel.backgroundColor = [UIColor greenColor];
    self.SJLabel.backgroundColor = [UIColor clearColor];
    self.SJLabel.textColor = [UIColor grayColor];
    self.SJLabel.font =[UIFont fontWithName:@"ArialMT" size:14];
    self.SJLabel.textAlignment = NSTextAlignmentCenter;
    self.SJLabel.lineBreakMode = NSLineBreakByWordWrapping;
    self.SJLabel.numberOfLines = 0;
    self.SJLabel.text = _sjStr;
    [subView addSubview:self.SJLabel];
    
//    联系电话
    self.LXDHLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.SJLabel.frame), 0, 110, 40)];
//    self.LXDHLabel.backgroundColor = [UIColor cyanColor];
    self.LXDHLabel.backgroundColor = [UIColor clearColor];
    self.LXDHLabel.textColor = [UIColor grayColor];
    self.LXDHLabel.font =[UIFont fontWithName:@"ArialMT" size:14];
    self.LXDHLabel.textAlignment = NSTextAlignmentCenter;
    self.LXDHLabel.lineBreakMode = NSLineBreakByWordWrapping;
    self.LXDHLabel.numberOfLines = 0;
    self.LXDHLabel.text = _lxdhStr;
    [subView addSubview:self.LXDHLabel];
//    联系人
    self.LXRLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.LXDHLabel.frame), 0, 110, 40)];
//    self.LXRLabel.backgroundColor = [UIColor blueColor];
    self.LXRLabel.backgroundColor = [UIColor clearColor];
    self.LXRLabel.textColor = [UIColor grayColor];
    self.LXRLabel.font =[UIFont fontWithName:@"ArialMT" size:14];
    self.LXRLabel.textAlignment = NSTextAlignmentCenter;
    self.LXRLabel.lineBreakMode = NSLineBreakByWordWrapping;
    self.LXRLabel.numberOfLines = 0;
    self.LXRLabel.text = _lxrStr;
    [subView addSubview:self.LXRLabel];
    
//    联系地址
    self.LXDZLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.LXRLabel.frame), 0, 123, 40)];
//    self.LXDZLabel.backgroundColor = [UIColor purpleColor];
    self.LXDZLabel.backgroundColor = [UIColor clearColor];
    self.LXDZLabel.textColor = [UIColor grayColor];
    self.LXDZLabel.font =[UIFont fontWithName:@"ArialMT" size:14];
    self.LXDZLabel.textAlignment = NSTextAlignmentCenter;
    self.LXDZLabel.lineBreakMode = NSLineBreakByWordWrapping;
    self.LXDZLabel.numberOfLines = 0;
    self.LXDZLabel.text = _lxdzStr;
    [subView addSubview:self.LXDZLabel];
    
}
#pragma 发动机
-(void)loadbuttonPictuer
{
//    CGRectMake(100, 190, 160, 30)
    self.engineField = [[UITextField alloc]initWithFrame:CGRectMake(100, 190, 160, 30)];
//    self.engineField = [[UITextField alloc]initWithFrame:CGRectMake(100, 235, 160, 30)];      //发动机号
    self.engineField.borderStyle = UITextBorderStyleLine;
    self.engineField.textColor = [UIColor grayColor];
    self.engineField.font = [UIFont fontWithName:@"ArialMT" size:14];
//    self.engineField.text = [self.carModifyDataDit objectForKey:@"engineNumber"];
    [self.engineField setTextAlignment:NSTextAlignmentCenter];
    self.engineField.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.backgroundView addSubview:self.engineField];
    
    self.transmissionField = [[UITextField alloc]initWithFrame:CGRectMake(100, 235, 160, 30)];
//    CGRectMake(100, 235, 160, 30)
//    self.transmissionField = [[UITextField alloc]initWithFrame:CGRectMake(100, 279, 160, 30)];      //变速箱号
    self.transmissionField.borderStyle = UITextBorderStyleLine;
    self.transmissionField.textColor = [UIColor grayColor];
    self.transmissionField.font = [UIFont fontWithName:@"ArialMT" size:14];
//    self.transmissionField.text = [self.carModifyDataDit objectForKey:@"gearBoxNumber"];
    [self.transmissionField setTextAlignment:NSTextAlignmentCenter];
    self.transmissionField.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.backgroundView addSubview:self.transmissionField];
    
////    CGRectMake(100, 368, 160, 30)
//    UILabel * label3 = [[UILabel alloc]initWithFrame:CGRectMake(100, 368, 160, 30)];
////    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(100, 412, 160, 30)];       //变速箱类型
//    [label3 setBackgroundColor:[UIColor clearColor]];
//    label3.layer.borderColor = [[UIColor grayColor]CGColor];
//    label3.layer.borderWidth = 0.8;
//    [self.backgroundView addSubview:label3];
//    self.transmissionType = [UIButton buttonWithType:UIButtonTypeCustom];//变速箱类型
//    [self.transmissionType setFrame:CGRectMake(101, 369, 158, 28)];
//    [self.transmissionType setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
//    [self.transmissionType addTarget:self action:@selector(transmissionType:) forControlEvents:UIControlEventTouchUpInside];
//    [self.transmissionType setTitle:[self.carModifyDataDit objectForKey:@"gearBoxNumbe"] forState:UIControlStateNormal];
//    self.transmissionType.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.transmissionType setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [self.backgroundView addSubview:self.transmissionType];
    
//    self.importantNotice = [[UITextField alloc]initWithFrame:CGRectMake(100, 455, 740, 30)];      //重要提示
//    self.importantNotice.borderStyle = UITextBorderStyleLine;
//    self.importantNotice.textColor = [UIColor grayColor];
//    self.importantNotice.font = [UIFont fontWithName:@"ArialMT" size:14];
//    self.importantNotice.text = [self.carModifyDataDit objectForKey:@"importantNotice"];
//    [self.importantNotice setTextAlignment:NSTextAlignmentCenter];
//    self.importantNotice.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
//    self.importantNotice.delegate = self;
//    [self.backgroundView addSubview:self.importantNotice];
    
    self.remark = [[UITextField alloc]initWithFrame:CGRectMake(100, 496-44-44-44, 740, 30)];      //备注
    self.remark.borderStyle = UITextBorderStyleLine;
    self.remark.textColor = [UIColor grayColor];
    self.remark.font = [UIFont fontWithName:@"ArialMT" size:14];
//    self.remark.text = [self.carModifyDataDit objectForKey:@"remark"];
    [self.remark setTextAlignment:NSTextAlignmentCenter];
    self.remark.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    self.remark.delegate = self;
    [self.backgroundView addSubview:self.remark];
    
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(365, 53, 160, 30)];        //内装颜色
    [label4 setBackgroundColor:[UIColor clearColor]];
    label4.layer.borderColor = [[UIColor grayColor]CGColor];
    label4.layer.borderWidth = 0.8;
    [self.backgroundView addSubview:label4];
    self.insideColor = [UIButton buttonWithType:UIButtonTypeCustom];//内装颜色
    [self.insideColor setFrame:CGRectMake(366, 54, 158, 28)];
    [self.insideColor setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.insideColor addTarget:self action:@selector(insideColor:) forControlEvents:UIControlEventTouchUpInside];
    [self.insideColor setTitle:[self.carModifyDataDit objectForKey:@"insideColor"] forState:UIControlStateNormal];
    self.insideColor.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.insideColor setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.backgroundView addSubview:self.insideColor];
    
    UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(365, 97, 160, 30)];         //车辆颜色
    [label5 setBackgroundColor:[UIColor clearColor]];
    label5.layer.borderColor = [[UIColor grayColor]CGColor];
    label5.layer.borderWidth = 0.8;
    [self.backgroundView addSubview:label5];
    self.carClolr = [UIButton buttonWithType:UIButtonTypeCustom];//车辆颜色
    [self.carClolr setFrame:CGRectMake(366, 98, 158, 28)];
    [self.carClolr setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.carClolr addTarget:self action:@selector(carClolr:) forControlEvents:UIControlEventTouchUpInside];
    [self.carClolr setTitle:[self.carModifyDataDit objectForKey:@"carColor"] forState:UIControlStateNormal];
    self.carClolr.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.carClolr setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.backgroundView addSubview:self.carClolr];
#pragma mark - 车主选择与保存按钮
    self.carMasterButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 578-44-44, 100, 38)];
    [self.carMasterButton setTitle:@"车 主" forState:UIControlStateNormal];
    [self.carMasterButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.carMasterButton setBackgroundImage:[UIImage imageNamed:@"改-灰but.png"] forState:UIControlStateNormal];
    [self.carMasterButton addTarget:self action:@selector(carMasterButton:) forControlEvents:UIControlEventTouchUpInside];
    self.carMasterButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.backgroundView addSubview:self.carMasterButton];
    
//    self.carUserButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 618-44-44, 100, 38)];
//    [self.carUserButton setTitle:@"驾驶员" forState:UIControlStateNormal];
//    [self.carUserButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [self.carUserButton setBackgroundImage:[UIImage imageNamed:@"改-灰but.png"] forState:UIControlStateNormal];
//    [self.carUserButton addTarget:self action:@selector(carUserButton:) forControlEvents:UIControlEventTouchUpInside];
//    self.carUserButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:14];
//    [self.carUserButton setEnabled:NO];
//    [self.backgroundView addSubview:self.carUserButton];
    
//    self.carDrivingButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 658-44-44, 100, 38)];
//    [self.carDrivingButton setTitle:@"使用者" forState:UIControlStateNormal];
//    [self.carDrivingButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [self.carDrivingButton setBackgroundImage:[UIImage imageNamed:@"改-灰but.png"] forState:UIControlStateNormal];
//    [self.carDrivingButton addTarget:self action:@selector(carDrivingButton:) forControlEvents:UIControlEventTouchUpInside];
//    self.carDrivingButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:14];
//    [self.carDrivingButton setEnabled:NO];
//    [self.backgroundView addSubview:self.carDrivingButton];
    
    self.saveButton = [[UIButton alloc]initWithFrame:CGRectMake(865, 60, 75, 33)];
    [self.saveButton setBackgroundImage:[UIImage imageNamed:@"ht05-1.png"] forState:UIControlStateNormal];
    [self.saveButton setTitle:@"保 存" forState:UIControlStateNormal];
    [self.saveButton setTintColor:[UIColor whiteColor]];
    self.saveButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.saveButton addTarget:self action:@selector(saveButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.saveButton];
}
#pragma 车辆信息编辑页面button
-(void)loadbuttonPictuerTwo
{
//    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(100, 97, 160, 30)];     //生产厂家
//    [label1 setBackgroundColor:[UIColor clearColor]];
//    label1.layer.borderColor = [[UIColor grayColor]CGColor];
//    label1.layer.borderWidth = 0.8;
//    [self.backgroundView addSubview:label1];
//    self.manufacturer = [UIButton buttonWithType:UIButtonTypeCustom];//生产厂家
//    [self.manufacturer setFrame:CGRectMake(101, 98, 158, 28)];
//    [self.manufacturer setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
//    [self.manufacturer addTarget:self action:@selector(manufacturer:) forControlEvents:UIControlEventTouchUpInside];
//    [self.manufacturer setTitle:[self.carModifyDataDit objectForKey:@"manufactureName"] forState:UIControlStateNormal];
//    self.manufacturer.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.manufacturer setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [self.backgroundView addSubview:self.manufacturer];
    
//    CGRectMake(100, 141, 160, 30)
//    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(100, 190, 160, 30)];        //型号
    UILabel * label2 = [[UILabel alloc]initWithFrame:CGRectMake(100, 141, 160, 30)];
    [label2 setBackgroundColor:[UIColor clearColor]];
    label2.layer.borderColor = [[UIColor grayColor]CGColor];
    label2.layer.borderWidth = 0.8;
    [self.backgroundView addSubview:label2];
    self.model = [UIButton buttonWithType:UIButtonTypeCustom];//型号
    [self.model setFrame:CGRectMake(101, 142, 158, 28)];
    [self.model setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.model addTarget:self action:@selector(model:) forControlEvents:UIControlEventTouchUpInside];
//    [self.model setTitle:[self.carModifyDataDit objectForKey:@"carType"] forState:UIControlStateNormal];
    self.model.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.model setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.backgroundView addSubview:self.model];
    
//    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(365, 190, 160, 30)];     //国家代码
//    [label3 setBackgroundColor:[UIColor clearColor]];
//    label3.layer.borderColor = [[UIColor grayColor]CGColor];
//    label3.layer.borderWidth = 0.8;
//    [self.backgroundView addSubview:label3];
//    UIImageView *xingxingimage7 = [[UIImageView alloc]initWithFrame:CGRectMake(275, 195, 10, 10)];
//    [xingxingimage7 setImage:[UIImage imageNamed:@"xingxing.png"]];
//    [self.backgroundView addSubview:xingxingimage7];
//
//    self.countriesCodeName = [UIButton buttonWithType:UIButtonTypeCustom];//国家代码
//    [self.countriesCodeName setFrame:CGRectMake(366, 191, 158, 28)];
//    [self.countriesCodeName setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
//    [self.countriesCodeName addTarget:self action:@selector(countriesCodeName:) forControlEvents:UIControlEventTouchUpInside];
//    [self.countriesCodeName setTitle:[self.carModifyDataDit objectForKey:@"countryCode"] forState:UIControlStateNormal];
//    self.countriesCodeName.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.countriesCodeName setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [self.backgroundView addSubview:self.countriesCodeName];

    UIImageView *xingxingimagechexi = [[UIImageView alloc]initWithFrame:CGRectMake(285, 195-45, 10, 10)];
    [xingxingimagechexi setImage:[UIImage imageNamed:@"xingxing.png"]];
    [self.backgroundView addSubview:xingxingimagechexi];
    UILabel *chexiLabel = [[UILabel alloc]initWithFrame:CGRectMake(365, 141, 160, 30)];
    [chexiLabel setBackgroundColor:[UIColor clearColor]];
    chexiLabel.layer.borderColor = [[UIColor grayColor]CGColor];
    chexiLabel.layer.borderWidth = 0.8;
    [self.backgroundView addSubview:chexiLabel];
    self.chexiBtn = [UIButton buttonWithType:UIButtonTypeCustom];//车辆用途
    [self.chexiBtn setFrame:CGRectMake(366, 142, 158, 28)];
    [self.chexiBtn setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.chexiBtn addTarget:self action:@selector(chexiBtnClick:) forControlEvents:UIControlEventTouchUpInside];
//    [self.chexiBtn setTitle:[self.carModifyDataDit objectForKey:@"typeofbuycar"] forState:UIControlStateNormal];
    self.chexiBtn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.chexiBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.backgroundView addSubview:self.chexiBtn];
    
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(365, 235, 160, 30)];     //车辆用途
    [label4 setBackgroundColor:[UIColor clearColor]];
    label4.layer.borderColor = [[UIColor grayColor]CGColor];
    label4.layer.borderWidth = 0.8;
    [self.backgroundView addSubview:label4];
    self.carUse = [UIButton buttonWithType:UIButtonTypeCustom];//车辆用途
    [self.carUse setFrame:CGRectMake(366, 236, 158, 28)];
    [self.carUse setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.carUse addTarget:self action:@selector(carUse:) forControlEvents:UIControlEventTouchUpInside];
    [self.carUse setTitle:[self.carModifyDataDit objectForKey:@"typeofbuycar"] forState:UIControlStateNormal];
    self.carUse.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.carUse setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.backgroundView addSubview:self.carUse];
    
    self.baoxiangongsi = [[UILabel alloc]initWithFrame:CGRectMake(675, 53, 160, 30)];     //保险公司
    [self.baoxiangongsi setBackgroundColor:[UIColor clearColor]];
    self.baoxiangongsi.layer.borderColor = [[UIColor grayColor]CGColor];
    self.baoxiangongsi.layer.borderWidth = 0.8;
    [self.backgroundView addSubview:self.baoxiangongsi];
    self.baoxiangongsiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.baoxiangongsiBtn setFrame:CGRectMake(676, 54, 158, 28)];
    [self.baoxiangongsiBtn setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.baoxiangongsiBtn addTarget:self action:@selector(baoxiangongsiBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.baoxiangongsiBtn setTitle:[self.carModifyDataDit objectForKey:@"INSURANCE_COMPANY"] forState:UIControlStateNormal];
    self.baoxiangongsiBtn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.baoxiangongsiBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.backgroundView addSubview:self.baoxiangongsiBtn];


    
//    self.baoxiangoumai = [[UILabel alloc]initWithFrame:CGRectMake(675, 97, 160, 30)];   //保险购买日期
//    [self.baoxiangoumai setBackgroundColor:[UIColor clearColor]];
//    self.baoxiangoumai.layer.borderColor = [[UIColor grayColor]CGColor];
//    self.baoxiangoumai.layer.borderWidth = 0.8;
//    [self.backgroundView addSubview:self.baoxiangoumai];
    
    //保险购买日期Btn
    UILabel * bxgmLabel = [[UILabel alloc]initWithFrame:CGRectMake(675, 97, 160, 30)];
    bxgmLabel.backgroundColor = [UIColor clearColor];
    bxgmLabel.layer.borderColor = [UIColor grayColor].CGColor;
    bxgmLabel.layer.borderWidth = 0.8;
    [self.backgroundView addSubview:bxgmLabel];
    
    self.baoxiangoumaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.baoxiangoumaiBtn.frame =CGRectMake(676, 98, 158, 28) ;
    [self.baoxiangoumaiBtn setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.baoxiangoumaiBtn addTarget:self action:@selector(baoxiangoumaiBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.baoxiangoumaiBtn setTitle:[self.carModifyDataDit objectForKey:@"INSURANCE_BUY_DATE"] forState:UIControlStateNormal];
    self.baoxiangoumaiBtn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.baoxiangoumaiBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.backgroundView addSubview:self.baoxiangoumaiBtn];
    
    
//    self.baoxiandaoqi = [[UILabel alloc]initWithFrame:CGRectMake(675, 141, 160, 30)];   //保险到期日期
//    [self.baoxiandaoqi setBackgroundColor:[UIColor clearColor]];
//    self.baoxiandaoqi.layer.borderColor = [[UIColor grayColor]CGColor];
//    self.baoxiandaoqi.layer.borderWidth = 0.8;
//    [self.backgroundView addSubview:self.baoxiandaoqi];
    
    
    UILabel * bxdqLabel = [[UILabel alloc]initWithFrame:CGRectMake(675, 141, 160, 30)];
    bxdqLabel.backgroundColor = [UIColor clearColor];
    bxdqLabel.layer.borderColor = [UIColor grayColor].CGColor;
    bxdqLabel.layer.borderWidth = 0.8;
    [self.backgroundView addSubview:bxdqLabel];
    
    self.baoxiandaoqiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.baoxiandaoqiBtn.frame =CGRectMake(676, 142, 158, 28) ;
    [self.baoxiandaoqiBtn setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.baoxiandaoqiBtn addTarget:self action:@selector(baoxiandaoqiBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.baoxiandaoqiBtn setTitle:[self.carModifyDataDit objectForKey:@"INSURANCE_EXPIRES_DATE"] forState:UIControlStateNormal];
    self.baoxiandaoqiBtn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.baoxiandaoqiBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.backgroundView addSubview:self.baoxiandaoqiBtn];
    
//    UILabel *label8 = [[UILabel alloc]initWithFrame:CGRectMake(675, 187, 160, 30)];   //年检开始日期
//    [label8 setBackgroundColor:[UIColor clearColor]];
//    label8.layer.borderColor = [[UIColor grayColor]CGColor];
//    label8.layer.borderWidth = 0.8;
//    [self.backgroundView addSubview:label8];
//    self.checkStartDate = [UIButton buttonWithType:UIButtonTypeCustom];//年检开始日期
//    [self.checkStartDate setFrame:CGRectMake(676, 188, 158, 28)];
//    [self.checkStartDate setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
//    [self.checkStartDate addTarget:self action:@selector(checkStartDate:) forControlEvents:UIControlEventTouchUpInside];
//    [self.checkStartDate setTitle:[self.carModifyDataDit objectForKey:@"yearCheckStartDate"] forState:UIControlStateNormal];
//    self.checkStartDate.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.checkStartDate setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [self.backgroundView addSubview:self.checkStartDate];
    
//    UILabel *label9 = [[UILabel alloc]initWithFrame:CGRectMake(675, 235, 160, 30)];   //购买日期
    UILabel * label9 = [[UILabel alloc]initWithFrame:CGRectMake(675, 187, 160, 30)];
    [label9 setBackgroundColor:[UIColor clearColor]];
    label9.layer.borderColor = [[UIColor grayColor]CGColor];
    label9.layer.borderWidth = 0.8;
    [self.backgroundView addSubview:label9];
    self.buyDate = [UIButton buttonWithType:UIButtonTypeCustom];  //购买日期
    [self.buyDate setFrame:CGRectMake(676, 188, 158, 28)];
    [self.buyDate setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.buyDate addTarget:self action:@selector(buyDate:) forControlEvents:UIControlEventTouchUpInside];
    [self.buyDate setTitle:[self.carModifyDataDit objectForKey:@"BuyDate"] forState:UIControlStateNormal];
    self.buyDate.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.buyDate setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.backgroundView addSubview:self.buyDate];
    
    UILabel * label10 = [[UILabel alloc]initWithFrame:CGRectMake(675, 235, 160, 30)];
//    UILabel *label10 = [[UILabel alloc]initWithFrame:CGRectMake(675, 279, 160, 30)];   //上牌日期
    [label10 setBackgroundColor:[UIColor clearColor]];
    label10.layer.borderColor = [[UIColor grayColor]CGColor];
    label10.layer.borderWidth = 0.8;
    [self.backgroundView addSubview:label10];
    self.registrationDate = [UIButton buttonWithType:UIButtonTypeCustom]; //上牌日期
    [self.registrationDate setFrame:CGRectMake(676, 236, 158, 28)];
    [self.registrationDate setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.registrationDate addTarget:self action:@selector(registrationDate:) forControlEvents:UIControlEventTouchUpInside];
//    [self.registrationDate setTitle:[self.carModifyDataDit objectForKey:@"plateDate"] forState:UIControlStateNormal];
    self.registrationDate.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.registrationDate setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.backgroundView addSubview:self.registrationDate];
    
//    UILabel *label11 = [[UILabel alloc]initWithFrame:CGRectMake(675, 324, 160, 30)];   //第一次来厂日期
    UILabel * label11= [[UILabel alloc]initWithFrame:CGRectMake(675, 279, 160, 30)];
    [label11 setBackgroundColor:[UIColor clearColor]];
    label11.layer.borderColor = [[UIColor grayColor]CGColor];
    label11.layer.borderWidth = 0.8;
    [self.backgroundView addSubview:label11];
    self.firstTimeDate = [UIButton buttonWithType:UIButtonTypeCustom];//第一次来厂日期
    [self.firstTimeDate setFrame:CGRectMake(676, 280, 158, 28)];
    [self.firstTimeDate setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.firstTimeDate addTarget:self action:@selector(firstTimeDate:) forControlEvents:UIControlEventTouchUpInside];
    [self.firstTimeDate setTitle:[self.carModifyDataDit objectForKey:@"firstComingDate"] forState:UIControlStateNormal];
    self.firstTimeDate.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.firstTimeDate setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.backgroundView addSubview:self.firstTimeDate];
    
    //最后一次来厂里程
//    self.lastComingMileage = [[UITextField alloc]initWithFrame:CGRectMake(675, 368, 160, 30)];
    self.lastComingMileage = [[UITextField alloc]initWithFrame:CGRectMake(675, 324, 160, 30)];
    self.lastComingMileage.borderStyle = UITextBorderStyleLine;
    self.lastComingMileage.textColor = [UIColor grayColor];
    self.lastComingMileage.font = [UIFont fontWithName:@"ArialMT" size:15];
//    self.lastComingMileage.text = [self.carModifyDataDit objectForKey:@"lastComingMileage"];
    [self.lastComingMileage setTextAlignment:NSTextAlignmentCenter];
    self.lastComingMileage.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    self.lastComingMileage.delegate = self;
    [self.backgroundView addSubview:self.lastComingMileage];
#pragma mark - 是否保修车辆选择按钮
//    self.WarrantyOptions = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.WarrantyOptions setFrame:CGRectMake(325, 320-90, 35, 36)];
//    [self.WarrantyOptions setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
//    [self.WarrantyOptions addTarget:self action:@selector(WarrantyOptions:) forControlEvents:UIControlEventTouchUpInside];
//    [self.backgroundView addSubview:self.WarrantyOptions];
}
#pragma mark - 年检开始日期的回调
-(void)checkStartDate:(id)sender
{
    self.datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 160)];
    self.datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    self.datePicker.datePickerMode = UIDatePickerModeDate;
    
    [self.datePicker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];
    //
    panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:self.datePicker];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = CGSizeMake(280.0f, 160.0f);
    
    [self.popCon presentPopoverFromRect:CGRectMake(70, 0, 5, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dateChanged:(id)sender
{
    UIDatePicker *contro = (UIDatePicker*)sender;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *str = [formatter stringFromDate:contro.date];
    [self.checkStartDate setTitle:str forState:UIControlStateNormal];
}
#pragma mark----  保险购买日期
-(void)baoxiangoumaiBtnClick:(id)sender{
    self.datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 160)];
    self.datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    self.datePicker.datePickerMode = UIDatePickerModeDate;
    
    [self.datePicker addTarget:self action:@selector(bxgmdateChanged:) forControlEvents:UIControlEventValueChanged];
    //
    panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:self.datePicker];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = CGSizeMake(280.0f, 160.0f);
    
    [self.popCon presentPopoverFromRect:CGRectMake(70, 0, 5, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

}
-(void)bxgmdateChanged:(id)sender
{
    UIDatePicker *contro = (UIDatePicker*)sender;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *str = [formatter stringFromDate:contro.date];
    [self.baoxiangoumaiBtn setTitle:str forState:UIControlStateNormal];
}
#pragma mark----  保险到期日期
-(void)baoxiandaoqiBtnClick:(id)sender{
    self.datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 160)];
    self.datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    self.datePicker.datePickerMode = UIDatePickerModeDate;
    
    [self.datePicker addTarget:self action:@selector(bxdqdateChanged:) forControlEvents:UIControlEventValueChanged];
    //
    panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:self.datePicker];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = CGSizeMake(280.0f, 160.0f);
    
    [self.popCon presentPopoverFromRect:CGRectMake(70, 0, 5, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
}
-(void)bxdqdateChanged:(id)sender
{
    UIDatePicker *contro = (UIDatePicker*)sender;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *str = [formatter stringFromDate:contro.date];
    [self.baoxiandaoqiBtn setTitle:str forState:UIControlStateNormal];
}

#pragma mark - 购买日期的回调
-(void)buyDate:(id)sender
{
    self.datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 160)];
    self.datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    self.datePicker.datePickerMode = UIDatePickerModeDate;
    
    [self.datePicker addTarget:self action:@selector(dateChanged1:) forControlEvents:UIControlEventValueChanged];
    //
    panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:self.datePicker];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = CGSizeMake(280.0f, 160.0f);
    
    [self.popCon presentPopoverFromRect:CGRectMake(70, 0, 5, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dateChanged1:(id)sender
{
    UIDatePicker *contro = (UIDatePicker*)sender;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *str = [formatter stringFromDate:contro.date];
    [self.buyDate setTitle:str forState:UIControlStateNormal];
}
#pragma mark - 上牌日期的回调
-(void)registrationDate:(id)sender
{
    self.datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 160)];
    self.datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    self.datePicker.datePickerMode = UIDatePickerModeDate;
    
    [self.datePicker addTarget:self action:@selector(dateChanged2:) forControlEvents:UIControlEventValueChanged];
    //
    panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:self.datePicker];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = CGSizeMake(280.0f, 160.0f);
    
    [self.popCon presentPopoverFromRect:CGRectMake(70, 0, 5, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dateChanged2:(id)sender
{
    UIDatePicker *contro = (UIDatePicker*)sender;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *str = [formatter stringFromDate:contro.date];
    [self.registrationDate setTitle:str forState:UIControlStateNormal];
}
#pragma mark - 第一次来厂日期的回调
-(void)firstTimeDate:(id)sender
{
    self.datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 160)];
    self.datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    self.datePicker.datePickerMode = UIDatePickerModeDate;
    
    [self.datePicker addTarget:self action:@selector(dateChanged3:) forControlEvents:UIControlEventValueChanged];
    //
    panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:self.datePicker];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = CGSizeMake(280.0f, 160.0f);
    
    [self.popCon presentPopoverFromRect:CGRectMake(70, 0, 5, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dateChanged3:(id)sender
{
    UIDatePicker *contro = (UIDatePicker*)sender;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *str = [formatter stringFromDate:contro.date];
    [self.firstTimeDate setTitle:str forState:UIControlStateNormal];
}
#pragma mark - 弹出窗口
-(void)popViewPicture
{
    self.keHuPopView = [[UIView alloc]initWithFrame:CGRectMake(60, 768, 1024-60-60, 768)];
    [self.keHuPopView setBackgroundColor:[UIColor whiteColor]];
    //    [self.backgroundView addSubview:self.keHuPopView];
    
    self.queryNameField = [[UITextField alloc]initWithFrame:CGRectMake(110, 150, 240, 30)];  //查询名称
    self.queryNameField.borderStyle = UITextBorderStyleLine;
    self.queryNameField.textColor = [UIColor grayColor];
    self.queryNameField.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.keHuPopView addSubview:self.queryNameField];
    
    self.queryNumberField = [[UITextField alloc]initWithFrame:CGRectMake(415, 150, 160, 30)];  //查询手机号
    self.queryNumberField.borderStyle = UITextBorderStyleLine;
    self.queryNumberField.textColor = [UIColor grayColor];
    self.queryNumberField.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.keHuPopView addSubview:self.queryNumberField];
    
    self.queryButton = [[UIButton alloc]initWithFrame:CGRectMake(680, 145, 75, 36)];
    [self.queryButton setBackgroundImage:[UIImage imageNamed:@"ht05-1.png"] forState:UIControlStateNormal];
    [self.queryButton setTitle:@"查 询" forState:UIControlStateNormal];
    [self.queryButton setTintColor:[UIColor whiteColor]];
    self.queryButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.queryButton addTarget:self action:@selector(queryButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.keHuPopView addSubview:self.queryButton];
    
    UILabel *bianhao = [[UILabel alloc]initWithFrame:CGRectMake(350, 150, 80, 30)];
    bianhao.text = @"手机号:";
    bianhao.backgroundColor = [UIColor clearColor];
    bianhao.textColor = [UIColor grayColor];
    bianhao.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.keHuPopView addSubview:bianhao];
    
    UILabel *mingchen = [[UILabel alloc]initWithFrame:CGRectMake(30, 150, 80, 30)];
    mingchen.text = @"客户名称:";
    mingchen.backgroundColor = [UIColor clearColor];
    mingchen.textColor = [UIColor grayColor];
    mingchen.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.keHuPopView addSubview:mingchen];
    
//    UILabel *delegate = [[UILabel alloc]initWithFrame:CGRectMake(520, 205, 80, 30)];
//    delegate.text = @"普通客户";
//    delegate.backgroundColor = [UIColor clearColor];
//    delegate.textColor = [UIColor grayColor];
//    delegate.font = [UIFont fontWithName:@"ArialMT" size:16];
//    [self.keHuPopView addSubview:delegate];
//    
//    UILabel *puTong = [[UILabel alloc]initWithFrame:CGRectMake(720, 205, 80, 30)];
//    puTong.text = @"协议客户";
//    puTong.backgroundColor = [UIColor clearColor];
//    puTong.textColor = [UIColor grayColor];
//    puTong.font = [UIFont fontWithName:@"ArialMT" size:16];
//    [self.keHuPopView addSubview:puTong];
//    //是否协议客户
//    self.customerTypeXy = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.customerTypeXy setFrame:CGRectMake(600, 200, 35, 36)];
//    [self.customerTypeXy setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
//    [self.customerTypeXy addTarget:self action:@selector(customerTypeXy:) forControlEvents:UIControlEventTouchUpInside];
//    [self.keHuPopView addSubview:self.customerTypeXy];
//    //是否普通客户
//    self.customerTypePt = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.customerTypePt setFrame:CGRectMake(800, 200, 35, 36)];
//    [self.customerTypePt setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
//    [self.customerTypePt addTarget:self action:@selector(customerTypePt:) forControlEvents:UIControlEventTouchUpInside];
//    [self.keHuPopView addSubview:self.customerTypePt];
    
    UILabel *dizhi = [[UILabel alloc]initWithFrame:CGRectMake(710-200, 250, 185, 40)];
    dizhi.text = @"联系地址";
    [dizhi setBackgroundColor:[[UIColor alloc]initWithRed:240.00/255 green:240.00/255 blue:240.00/255 alpha:1]];
    dizhi.textColor = [UIColor grayColor];
    dizhi.font = [UIFont fontWithName:@"ArialMT" size:15];
    [dizhi setTextAlignment:NSTextAlignmentCenter];
    [self.keHuPopView addSubview:dizhi];
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [backButton setImage:[UIImage imageNamed:@"返回下.png"] forState:UIControlStateNormal];
    [backButton setFrame:CGRectMake(20, 48, 65, 40)];
    [backButton addTarget:self action:@selector(chaxunbalck:) forControlEvents:UIControlEventTouchUpInside];
    [self.keHuPopView addSubview:backButton];
    
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 105, 980, 11)];
    image.image = [UIImage imageNamed:@"渐变分割线.png"];
    [self.keHuPopView addSubview:image];
    UILabel *imagetitel = [[UILabel alloc]initWithFrame:CGRectMake(110, 55, 180, 35)];
    imagetitel.text = @"客户信息查询";
    imagetitel.backgroundColor = [UIColor clearColor];
    imagetitel.textColor = [UIColor grayColor];
    imagetitel.font = [UIFont fontWithName:@"ArialMT" size:28];
    [self.keHuPopView addSubview:imagetitel];
    
    NSMutableArray *labelMutabelArrayOne = [[NSMutableArray alloc]initWithObjects:@"客户编号",@"客户名称",@"固定电话",@"联系人",@"手机", nil];
//    ,@"地区",@"传真"
    for(int i = 0; i < 5;i++)
    {
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake((0+i*100), 250, 110, 40)];
        [titlelabel setBackgroundColor:[[UIColor alloc]initWithRed:240.00/255 green:240.00/255 blue:240.00/255 alpha:1]];
        titlelabel.text = [labelMutabelArrayOne objectAtIndex:i];
        [titlelabel setTextColor:[UIColor grayColor]];
        titlelabel.font = [UIFont fontWithName:@"ArialMT" size:15];
        [titlelabel setTextAlignment:NSTextAlignmentCenter];
        [self.keHuPopView addSubview:titlelabel];
    }
    self.queryTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 290, 895-200, 280) style:UITableViewStylePlain];
    [self.queryTableView setDataSource:self];
    [self.queryTableView setDelegate:self];
    [self.keHuPopView addSubview:self.queryTableView];
    
    __unsafe_unretained UITableView *table1 = self.queryTableView;
    table1.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        //        [self.tableViewDataArrS removeAllObjects];
        to = 10;
        [self queryButton:nil];
        
        [table1.mj_header endRefreshing];
    }];
    
    
    table1.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
        to = to +10;
        [self queryButton:nil];
        [table1.mj_footer endRefreshing];
    }];
}
#pragma mark - 是否协议客户按钮的回调
-(void)customerTypeXy:(id)sender
{
    _TypePt = NO;
    if(_TypeXy == NO)
    {
        [self.customerTypeXy setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
        [self.customerTypePt setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
        _TypeXy = YES;
    }
    else
    {
        _TypeXy = NO;
        [self.customerTypeXy setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
}
#pragma mark - 是否普通客户按钮的回调
-(void)customerTypePt:(id)sender
{
    _TypeXy = NO;
    if(_TypePt == NO)
    {
        [self.customerTypePt setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
        [self.customerTypeXy setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
        _TypePt = YES;
    }
    else
    {
        _TypePt = NO;
        [self.customerTypePt setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
}

#pragma mark - 弹出窗查询按钮的回调
-(void)queryButton:(id)sender
{
   [SVProgressHUD showWithStatus:@"请等待...."];
//    webService *web = [[webService alloc]init];
//    web.methodName = SEARCHCUSTOMERLIST;
    //searchCustomerList
    NSMutableArray *queryArray = [[NSMutableArray alloc]init];
    self.queryDic = [[NSMutableDictionary alloc]init];
  
//    [queryDic setValue:@"0" forKey:@"FROM"];
//    [queryDic setValue:@"10" forKey:@"TO"];

    
    if(self.queryNumberField.text.length != 0)
    {
//        修改为 查询手机号
        NSString * str = [self.queryNumberField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [self.queryDic setValue:str forKey:@"MOBILE"];
        [queryArray addObject:@"customerId"];
        [queryArray addObject:self.queryNumberField.text];
    }
    if(self.queryNameField.text.length != 0)
    {
        //查询客户名称
          NSString * str = [self.queryNameField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [self.queryDic setValue:str forKey:@"CUSTOMER_NAME"];
        [queryArray addObject:@"customerName"];
        [queryArray addObject:self.queryNameField.text];
    }
//    if(_TypeXy == YES)
//    {
//        [queryArray addObject:@"customerType"];
//        [queryArray addObject:@"0"];
//    }
//    if(_TypePt == YES)
//    {
//        [queryArray addObject:@"customerType"];
//        [queryArray addObject:@"1"];
//    }
////    NSLog(@"%@",queryArray);//(customerId,22222,customerName,222222,customerType,1)
//    [web commonGetSharedRequest:SEARCHCUSTOMERLIST wsparas:queryArray];
    [self.queryDic setValue:[NSString stringWithFormat:@"%d",from] forKey:@"FROM"];
    [self.queryDic setValue:[NSString stringWithFormat:@"%d",to] forKey:@"TO"];
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        //api调用及返回
        [MyAFNetWorkManager postWithParam:self.queryDic andAction:@"QUERY_OWNER" finish:^(NSData *data, NSDictionary *obj, NSError *error) {
            [SVProgressHUD dismiss];
            if (error == nil)
            {
                NSLog(@"车主查询 json is %@",obj);
                NSDictionary *dic = obj;
                if([[dic valueForKey:@"SUCCESS"] integerValue]==1)
                {
                    NSArray *array = [dic objectForKey:@"TM_OWNER"];
                
                    [self.queryDataArray removeAllObjects];
                        [self.queryDataArray setArray:array];
                        [self.queryTableView reloadData];
                
                    
                }
            }
            else{
                [SVProgressHUD showErrorWithStatus:error.localizedDescription];
            }
            
        }];
    });

}
-(void)searchCustomerList:(NSNotification *)notification
{
    NSMutableDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData *)notification.object options:NSJSONReadingMutableLeaves error:Nil];
    self.queryDataArray = [NSMutableArray arrayWithArray:[theJson objectForKey:@"customerList"]];
//    NSLog(@"%@",self.queryDataArray);
    [self.queryTableView reloadData];
    [SVProgressHUD dismiss];
}

-(void)chaxunbalck:(id)sender
{
    [self.queryDataArray removeAllObjects];
    [UIView animateWithDuration:0.5 animations:^{
        [self.keHuPopView setFrame:CGRectMake(0, 768, 1024, 768)];
    }completion:^(BOOL finished) {
        [self.keHuPopView setHidden:YES];
    }];
}
#pragma mark - 各种输入框
-(void)Avarietyoftextfield
{
//    self.warrantyNumber = [[UITextField alloc]initWithFrame:CGRectMake(365, 279, 160, 30)];  //保修序号
//    self.warrantyNumber.borderStyle = UITextBorderStyleLine;
//    self.warrantyNumber.textColor = [UIColor grayColor];
//    self.warrantyNumber.font = [UIFont fontWithName:@"ArialMT" size:14];
//    self.warrantyNumber.text = @"";
//    [self.warrantyNumber setTextAlignment:NSTextAlignmentCenter];
//    self.warrantyNumber.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
//    [self.backgroundView addSubview:self.warrantyNumber];
    
//    self.monthsOfNumber = [[UILabel alloc]initWithFrame:CGRectMake(365, 368, 160, 30)];  //保修月数
//    self.monthsOfNumber.layer.borderColor = [[UIColor grayColor]CGColor];
//    self.monthsOfNumber.layer.borderWidth = 1.0;
//    self.monthsOfNumber.textColor = [UIColor grayColor];
//    [self.monthsOfNumber setHidden:NO];
//    self.monthsOfNumber.font = [UIFont fontWithName:@"ArialMT" size:14];
//    self.monthsOfNumber.text = [self.carModifyDataDit objectForKey:@"WarrantyMonths"];
//    [self.monthsOfNumber setTextAlignment:NSTextAlignmentCenter];
//    [self.backgroundView addSubview:self.monthsOfNumber];
    
//    self.layerLabel = [[UILabel alloc]initWithFrame:CGRectMake(365, 368, 160, 30)];   //保修到期日
//    [self.layerLabel setBackgroundColor:[UIColor clearColor]];
//    self.layerLabel.layer.borderColor = [[UIColor grayColor]CGColor];
//    self.layerLabel.layer.borderWidth = 0.8;
//    [self.layerLabel setHidden:YES];
//    [self.backgroundView addSubview:self.layerLabel];
//    self.baoXiuDaoQiRi = [UIButton buttonWithType:UIButtonTypeCustom];//保修到期日
//    [self.baoXiuDaoQiRi setFrame:CGRectMake(366, 369, 158, 28)];
//    [self.baoXiuDaoQiRi setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
//    [self.baoXiuDaoQiRi addTarget:self action:@selector(baoXiuDaoQiRi:) forControlEvents:UIControlEventTouchUpInside];
//    [self.baoXiuDaoQiRi setTitle:@"请选择" forState:UIControlStateNormal];
//    self.baoXiuDaoQiRi.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.baoXiuDaoQiRi setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [self.baoXiuDaoQiRi setHidden:YES];
//    [self.backgroundView addSubview:self.baoXiuDaoQiRi];
    
//    self.licenseplate = [[UITextField alloc]initWithFrame:CGRectMake(100, 141, 160, 30)];  //车牌号
    self.licenseplate = [[UITextField alloc]initWithFrame:CGRectMake(100, 97, 160, 30)];
    self.licenseplate.borderStyle = UITextBorderStyleLine;
    self.licenseplate.textColor = [UIColor grayColor];
    self.licenseplate.font = [UIFont fontWithName:@"ArialMT" size:14];
//    self.licenseplate.text = [self.carModifyDataDit objectForKey:@"plateNumber"];
    [self.licenseplate setTextAlignment:NSTextAlignmentCenter];
    self.licenseplate.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.backgroundView addSubview:self.licenseplate];
    
    self.carframe = [[UITextField alloc]initWithFrame:CGRectMake(100, 53, 160, 30)];    //车架号
    self.carframe.autocapitalizationType=UITextAutocapitalizationTypeAllCharacters;
    self.carframe.borderStyle = UITextBorderStyleLine;
    self.carframe.textColor = [UIColor grayColor];
    self.carframe.font = [UIFont fontWithName:@"ArialMT" size:14];
//    self.carframe.text = [self.carModifyDataDit objectForKey:@"vin"];
    [self.carframe setTextAlignment:NSTextAlignmentCenter];
    self.carframe.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.backgroundView addSubview:self.carframe];
    
//    CGRectMake(100, 279, 160, 30)
    self.Inparagraph = [[UITextField alloc]initWithFrame:CGRectMake(100, 279, 160, 30)];
//    self.Inparagraph = [[UITextField alloc]initWithFrame:CGRectMake(100, 324, 160, 30)];    //年款
    self.Inparagraph.borderStyle = UITextBorderStyleLine;
    self.Inparagraph.textColor = [UIColor grayColor];
    self.Inparagraph.font = [UIFont fontWithName:@"ArialMT" size:14];
    self.Inparagraph.text = [self.carModifyDataDit objectForKey:@"year"];
    [self.Inparagraph setTextAlignment:NSTextAlignmentCenter];
    self.Inparagraph.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    self.Inparagraph.delegate = self;
    [self.backgroundView addSubview:self.Inparagraph];
//    CGRectMake(100, 324, 160, 30)
    self.exhaust = [[UITextField alloc]initWithFrame:CGRectMake(100, 324, 160, 30)];
//    self.exhaust = [[UITextField alloc]initWithFrame:CGRectMake(100, 368, 160, 30)];      //排气量
    self.exhaust.borderStyle = UITextBorderStyleLine;
    self.exhaust.textColor = [UIColor grayColor];
    self.exhaust.font = [UIFont fontWithName:@"ArialMT" size:14];
    self.exhaust.text = [self.carModifyDataDit objectForKey:@"emission"];
    [self.exhaust setTextAlignment:NSTextAlignmentCenter];
    self.exhaust.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    self.exhaust.delegate = self;
    [self.backgroundView addSubview:self.exhaust];
    
    self.keyNumber = [[UITextField alloc]initWithFrame:CGRectMake(365, 141+45, 160, 30)];      //钥匙号
    self.keyNumber.borderStyle = UITextBorderStyleLine;
    self.keyNumber.textColor = [UIColor grayColor];
    self.keyNumber.font = [UIFont fontWithName:@"ArialMT" size:14];
    //    self.keyNumber.text = [self.carModifyDataDit objectForKey:@"manufactureName"];
    [self.keyNumber setTextAlignment:NSTextAlignmentCenter];
    self.keyNumber.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.backgroundView addSubview:self.keyNumber];
    
    
    
    self.liChenShuRu = [[UITextField alloc]initWithFrame:CGRectMake(365, 412-44-44-44, 160, 30)];      //保修里程
    self.liChenShuRu.borderStyle = UITextBorderStyleLine;
    self.liChenShuRu.textColor = [UIColor grayColor];
    self.liChenShuRu.font = [UIFont fontWithName:@"ArialMT" size:14];
    self.liChenShuRu.text = [self.carModifyDataDit objectForKey:@"WarrantyMileage"];
    [self.liChenShuRu setTextAlignment:NSTextAlignmentCenter];
    self.liChenShuRu.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.liChenShuRu setHidden:YES];
    [self.backgroundView addSubview:self.liChenShuRu];
}
#pragma mark - 车主选择按钮的回调
-(void)carMasterButton:(id)sender
{
    _currentButton = self.carMasterButton;

    [self popViewPicture];
    
    [self.view addSubview:self.keHuPopView];
    [UIView animateWithDuration:0.5 animations:^{
        [self.keHuPopView setFrame:CGRectMake(60, 0, 1024-60-60, 768)];
    }completion:^(BOOL finished) {
        
    }];
}
#pragma mark - 使用者按钮的回调
-(void)carUserButton:(id)sender
{
    _currentButton = self.carUserButton;

    [self popViewPicture];
    
    [self.view addSubview:self.keHuPopView];
    [UIView animateWithDuration:0.5 animations:^{
        [self.keHuPopView setFrame:CGRectMake(60, 0, 1024-60-60, 768)];
    }completion:^(BOOL finished) {
        
    }];
}
#pragma mark - 驾驶员按钮的回调
-(void)carDrivingButton:(id)sender
{
    _currentButton = self.carDrivingButton;

    [self popViewPicture];
    
    [self.view addSubview:self.keHuPopView];
    [UIView animateWithDuration:0.5 animations:^{
        [self.keHuPopView setFrame:CGRectMake(60, 0, 1024-60-60, 768)];
    }completion:^(BOOL finished) {
        
    }];
}
#pragma mark - 是否保修车辆选择按钮的回调
-(void)WarrantyOptions:(id)sender
{
    if(_warrantyChoose == YES)
    {
        _warrantyChoose = NO;
        [self.WarrantyOptions setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
        [self.monthsOfNumber setHidden:NO];
        [self.layerLabel setHidden:YES];
        [self.baoXiuDaoQiRi setHidden:YES];
        self.baoXiuDaoQi.text = @"   保修月数:";
        [self.baoXiuLiChen setHidden:YES];
        [self.liChenShuRu setHidden:YES];
    }
    else
    {
        _warrantyChoose = YES;
        [self.WarrantyOptions setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
        [self.monthsOfNumber setHidden:YES];
        [self.layerLabel setHidden:NO];
        [self.baoXiuDaoQiRi setHidden:NO];
        self.baoXiuDaoQi.text = @"保修到期日:";
        [self.baoXiuLiChen setHidden:NO];
        [self.liChenShuRu setHidden:NO];
    }
}
#pragma mark - 各种下拉菜单的回调
//**** 生产厂家
//-(void)manufacturer:(id)sender
//{
//    webService *webcon = [[webService alloc]init];
//    webcon.methodName = GETMANUFACTURELIST;
//    [webcon commonGetSharedRequest:GETMANUFACTURELIST wsparas:nil];
//    
//    if (!contentCon) {
//        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
//    }
//    contentCon.delegate = self;
//    contentCon.btnSender=sender;
//    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
//    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
//    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
//    [DDPopoverBackgroundView setArrowHeight:15.0];
//    [DDPopoverBackgroundView setContentInset:1.0];
//    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
//    [self.popCon setPopoverContentSize:CGSizeMake(self.manufacturer.frame.size.width, 160)];
//    [self.popCon presentPopoverFromRect:CGRectMake(12, 10, 135, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
//}
//-(void)getManufactureList:(NSNotification*)notification{
//    
//    NSDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData*)notification.object options:NSJSONReadingMutableLeaves error:Nil];
//    self.manufacturerArray = [theJson objectForKey:@"manufactureList"];
//    NSMutableArray *carTypeArray=[[NSMutableArray alloc] init];
//    
//    for (int i=0; i<[[theJson objectForKey:@"manufactureList"] count]; i++) {
//        
//        [carTypeArray addObject: [[[theJson objectForKey:@"manufactureList"] objectAtIndex:i] objectForKey:@"manufactureName"]];
//    }
//    contentCon.list = carTypeArray;
//    [contentCon.myTableView reloadData];
//}
//**** 车型
-(void)model:(id)sender
{
//    webService *web=[[webService alloc] init];
//    web.methodName = GETCARTYPENAMELIST;
//    [web commonGetSharedRequest:GETCARTYPENAMELIST wsparas:nil];
    if (self.chexiBtn.titleLabel.text.length == 0) {
        UIAlertView *alerVeiw = [[UIAlertView alloc] initWithTitle:@"请选择车辆" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alerVeiw show];
        return;
    }
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.model.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(12, 10, 135, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSArray *zidianArr=[self readershuDICimform][@"MODEL"];
    NSMutableArray *modelArr = [[NSMutableArray alloc]init];
    [self.carTypeArray removeAllObjects];
    
//    for(NSDictionary *dic in zidianArr)
//    {
//        if ([dic[@"SERIES_CODE"] isEqualToString:self.carClassId]) {
//            [modelArr addObject:dic[@"MODEL_NAME"]];
//            [self.carTypeArray addObject:dic[@"MODEL_CODE"]];
//        }
//        
//    }
    for(NSDictionary *dic in zidianArr)
    {
        if ([dic[@"SERIES_CODE"] isEqualToString:self.chexiStr]) {
        [modelArr addObject:dic[@"MODEL_NAME"]];
        [self.carTypeArray addObject:dic[@"MODEL_CODE"]];
        }
    }
    contentCon.list = modelArr;
    [contentCon.myTableView reloadData];
}

//chexiBtnClick
//**** 车系
-(void)chexiBtnClick:(id)sender
{
    //    webService *web=[[webService alloc] init];
    //    web.methodName = GETCARTYPENAMELIST;
    //    [web commonGetSharedRequest:GETCARTYPENAMELIST wsparas:nil];
    
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.chexiBtn.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(12, 10, 135, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSArray *zidianArr=[self readershuDICimform][@"SERIES"];
    
    NSMutableArray *seriesArr = [[NSMutableArray alloc]init];
    [self.chexiArr removeAllObjects];
    
    for(NSDictionary *dic in zidianArr)
    {
        [seriesArr addObject:dic[@"SERIES_NAME"]];
        [self.chexiArr addObject:dic[@"SERIES_CODE"]];
    }
    
    contentCon.list = seriesArr;
    [contentCon.myTableView reloadData];
}

-(void)getCarType:(NSNotification*)notification{
    
    NSDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData*)notification.object options:NSJSONReadingMutableLeaves error:Nil];
    self.carTypeArray = [theJson objectForKey:@"results"];
    NSMutableArray *carTypeArray=[[NSMutableArray alloc] init];
    
    for (int i=0; i<[[theJson objectForKey:@"results"] count]; i++) {
        
        [carTypeArray addObject: [[[theJson objectForKey:@"results"] objectAtIndex:i] objectForKey:@"carTypeName"]];
    }
    contentCon.list = carTypeArray;
    [contentCon.myTableView reloadData];
}

//**** 国家代码
-(void)countriesCodeName:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.countriesCodeName.frame.size.width, 80)];
    [self.popCon presentPopoverFromRect:CGRectMake(12, 10, 135, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSMutableArray *carTypeArray=[[NSMutableArray alloc] init];
    [carTypeArray addObject:@"CHN"];
    [carTypeArray addObject:@"JPN"];
    
    contentCon.list = carTypeArray;
    [contentCon.myTableView reloadData];
}
//**** 车辆用途
-(void)carUse:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.carUse.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(12, 10, 135, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSArray *zidianArr=[self readershuDICimform][@"VEHICLE_PURPOSE"];
    NSMutableArray *useArr = [[NSMutableArray alloc]init];
    [self.carUseArray removeAllObjects];
    
    for(NSDictionary *dic in zidianArr)
    {
        [useArr addObject:dic[@"NAME"]];
        [self.carUseArray addObject:dic[@"CODE"]];
    }
    contentCon.list = useArr;

    [contentCon.myTableView reloadData];
}
/*
//**** 变速箱类型
-(void)transmissionType:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.transmissionType.frame.size.width, 200)];
    [self.popCon presentPopoverFromRect:CGRectMake(12, 10, 135, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSMutableArray *carTypeArray=[[NSMutableArray alloc] init];
    [carTypeArray addObject:@"5AT"];
    [carTypeArray addObject:@"5MT"];
    [carTypeArray addObject:@"AT"];
    [carTypeArray addObject:@"CVT"];
    [carTypeArray addObject:@"MT"];
    
    contentCon.list = carTypeArray;
    [contentCon.myTableView reloadData];
}
*/
-(NSMutableDictionary *)readershuDICimform
{
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path=[paths objectAtIndex:0];
    NSString *str=[path stringByAppendingPathComponent:@"Dic.text"];
    dic=[NSMutableDictionary dictionaryWithContentsOfFile:str];
    //nslog(@"%@",dic);
    return dic;
}

#pragma mark  --  保险公司回调
-(void)baoxiangongsiBtnClick:(id)sender{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.insideColor.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(12, 10, 135, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    

    NSArray *zidianArr=[self readershuDICimform][@"TM_INSURANCE"];
    NSMutableArray *innerColorArr = [[NSMutableArray alloc]init];
    [self.baoxiangongsiArray removeAllObjects];
    
    for(NSDictionary *dic in zidianArr)
    {
        [innerColorArr addObject:dic[@"NAME"]];
        [self.baoxiangongsiArray addObject:dic[@"CODE"]];
    }
    contentCon.list = innerColorArr;
    [contentCon.myTableView reloadData];

}
//**** 内装颜色
-(void)insideColor:(id)sender
{
//    webService *web=[[webService alloc] init];
//    web.methodName = GETCARINNERCOLORLIST;
//    [web commonGetSharedRequest:GETCARINNERCOLORLIST wsparas:nil];
    
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.insideColor.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(12, 10, 135, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    

    
    NSArray *zidianArr=[self readershuDICimform][@"INNER_COLOR"];
    NSMutableArray *innerColorArr = [[NSMutableArray alloc]init];
    [self.carInerColorArray removeAllObjects];
    
    for(NSDictionary *dic in zidianArr)
    {
        [innerColorArr addObject:dic[@"COLOR_NAME"]];
        [self.carInerColorArray addObject:dic[@"COLOR_CODE"]];
    }
    contentCon.list = innerColorArr;
    [contentCon.myTableView reloadData];
    
}
-(void)getCarInnerColorList:(NSNotification*)notification{
    
    NSDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData*)notification.object options:NSJSONReadingMutableLeaves error:Nil];
    self.carInerColorArray = [theJson objectForKey:@"results"];
    NSMutableArray *carInerColorArray=[[NSMutableArray alloc] init];
    
    for (int i=0; i<[[theJson objectForKey:@"results"] count]; i++) {
        
        [carInerColorArray addObject: [[[theJson objectForKey:@"results"] objectAtIndex:i] objectForKey:@"carInerColorName"]];
    }
    contentCon.list = carInerColorArray;
    [contentCon.myTableView reloadData];
}

//**** 车辆颜色
-(void)carClolr:(id)sender
{
//    webService *web=[[webService alloc] init];
//    web.methodName = GETCARCOLORLIST;
//    [web commonGetSharedRequest:GETCARCOLORLIST wsparas:nil];
    
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.carClolr.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(12, 10, 135, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSArray *zidianArr=[self readershuDICimform][@"OUTER_COLOR"];
    NSMutableArray *outerColorArr = [[NSMutableArray alloc]init];
    [self.carColorArray removeAllObjects];
    
    for(NSDictionary *dic in zidianArr)
    {
        [outerColorArr addObject:dic[@"COLOR_NAME"]];
        [self.carColorArray addObject:dic[@"COLOR_CODE"]];
    }
    contentCon.list = outerColorArr;
    [contentCon.myTableView reloadData];
}
-(void)getcarColorList:(NSNotification*)notification{
    
    NSDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData*)notification.object options:NSJSONReadingMutableLeaves error:Nil];
    self.carColorArray = [theJson objectForKey:@"results"];
    NSMutableArray *carColorArray=[[NSMutableArray alloc] init];
    
    for (int i=0; i<[[theJson objectForKey:@"results"] count]; i++) {
        
        [carColorArray addObject: [[[theJson objectForKey:@"results"] objectAtIndex:i] objectForKey:@"carColorName"]];
    }
    contentCon.list = carColorArray;
    [contentCon.myTableView reloadData];
}

//**** 保修到期日
-(void)baoXiuDaoQiRi:(id)sender
{
    self.datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 160)];
    self.datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    self.datePicker.datePickerMode = UIDatePickerModeDate;
    
    [self.datePicker addTarget:self action:@selector(dateChanged5:) forControlEvents:UIControlEventValueChanged];
    //
    panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:self.datePicker];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = CGSizeMake(280.0f, 160.0f);
    
    [self.popCon presentPopoverFromRect:CGRectMake(70, 0, 5, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dateChanged5:(id)sender
{
    UIDatePicker *contro = (UIDatePicker*)sender;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *str = [formatter stringFromDate:contro.date];
    [self.baoXiuDaoQiRi setTitle:str forState:UIControlStateNormal];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(tableView == self.queryTableView)
    {
        return [self.queryDataArray count];
    }
    if(tableView == self.subNewTableView)
    {
        return [self.CarModifyDataArray count];
    }
    return 0;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    NSLog(@"didselectrow %@----%@",indexPath,self.queryDataArray);
    [UIView animateWithDuration:0.5 animations:^{
         self.KHBHLabel.text = [[self.queryDataArray objectAtIndex:indexPath.row]objectForKey:@"CUSTOMER_ID"];
        self.KHMCLabel.text = [[self.queryDataArray objectAtIndex:indexPath.row] objectForKey:@"CUSTOMER_NAME"];
        self.KHXZLabel.text = [[[self.queryDataArray objectAtIndex:indexPath.row] objectForKey:@"NATURE_NAME"] stringValue];
        self.SJLabel.text = [[self.queryDataArray objectAtIndex:indexPath.row] objectForKey:@"MOBILE"];
        self.LXDHLabel.text = [[self.queryDataArray objectAtIndex:indexPath.row] objectForKey:@"TEL"];
       
        self.LXRLabel.text = [[self.queryDataArray objectAtIndex:indexPath.row] objectForKey:@"CONTACT_MAN"];
        self.LXDZLabel.text = [[self.queryDataArray objectAtIndex:indexPath.row] objectForKey:@"ADDRESS"];
        
    [self.keHuPopView setFrame:CGRectMake(0, 768, 1024, 768)];
    }completion:^(BOOL finished) {
        [self.keHuPopView setHidden:YES];
    }];
    /*
    if(tableView == self.queryTableView)
    {
        self.queryRowData = [NSMutableDictionary dictionaryWithDictionary:[self.queryDataArray objectAtIndex:[indexPath row]]];
//        NSLog(@"%@",self.queryRowData);
        if(_currentButton == self.carMasterButton)
        {
            if (!self.carDrivingButton.enabled)
            {
                NSMutableDictionary *tmpDic= [NSMutableDictionary dictionaryWithDictionary:self.queryRowData];
                [tmpDic setObject:@"车主" forKey:@"customerRole"];
                [self.CarModifyDataArray setObject:tmpDic atIndexedSubscript:0];

                
                NSMutableDictionary *tmpDic1= [NSMutableDictionary dictionaryWithDictionary:self.queryRowData];
                [tmpDic1 setObject:@"驾驶员" forKey:@"customerRole"];
                [self.CarModifyDataArray setObject:tmpDic1 atIndexedSubscript:1];
                

                NSMutableDictionary *tmpDic2= [NSMutableDictionary dictionaryWithDictionary:self.queryRowData];
                [tmpDic2 setObject:@"使用者" forKey:@"customerRole"];
                [self.CarModifyDataArray setObject:tmpDic2 atIndexedSubscript:2];
            }
            else
            {
                self.CarModifyDataArray = [NSMutableArray arrayWithArray:self.CarModifyDataArray];
                [self.queryRowData setObject:@"车主" forKey:@"customerRole"];
                [self.CarModifyDataArray setObject:self.queryRowData atIndexedSubscript:0];
            }
            [self.subNewTableView reloadData];
            [UIView animateWithDuration:0.5 animations:^{
                [self.keHuPopView setFrame:CGRectMake(0, 768, 1024, 768)];
            }completion:^(BOOL finished) {
                [self.keHuPopView setHidden:YES];
            }];
            
            [self.carUserButton setEnabled:YES];
            [self.carDrivingButton setEnabled:YES];
        }
        if(_currentButton == self.carUserButton)
        {
            self.CarModifyDataArray = [NSMutableArray arrayWithArray:self.CarModifyDataArray];
            [self.queryRowData setObject:@"驾驶员" forKey:@"customerRole"];
            [self.CarModifyDataArray setObject:self.queryRowData atIndexedSubscript:1];
            [self.subNewTableView reloadData];
            [UIView animateWithDuration:0.5 animations:^{
                [self.keHuPopView setFrame:CGRectMake(0, 768, 1024, 768)];
            }completion:^(BOOL finished) {
                [self.keHuPopView setHidden:YES];
            }];
        }
        if(_currentButton == self.carDrivingButton)
        {
            self.CarModifyDataArray = [NSMutableArray arrayWithArray:self.CarModifyDataArray];
            [self.queryRowData setObject:@"使用者" forKey:@"customerRole"];
            [self.CarModifyDataArray setObject:self.queryRowData atIndexedSubscript:2];
            [self.subNewTableView reloadData];
            [UIView animateWithDuration:0.5 animations:^{
                [self.keHuPopView setFrame:CGRectMake(0, 768, 1024, 768)];
            }completion:^(BOOL finished) {
                [self.keHuPopView setHidden:YES];
            }];
        }
    }
     */
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = [indexPath row];
    if(tableView == self.subNewTableView)
    {
        static NSString *indetfire = @"cell";
        CarCustomerInKeHuCell *cell = (CarCustomerInKeHuCell *)[tableView dequeueReusableCellWithIdentifier:indetfire];
        if(nil == cell)
        {
            cell = [[CarCustomerInKeHuCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indetfire];
            tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        }
        cell.cellLabelTwo.text = [[self.CarModifyDataArray objectAtIndex:row]objectForKey:@"customerId"];
        cell.cellLabelThree.text = [[self.CarModifyDataArray objectAtIndex:row]objectForKey:@"customerName"];
        cell.cellLabelFour.text = [[self.CarModifyDataArray objectAtIndex:row]objectForKey:@"natureName"];
        cell.cellLabelFive.text = [[self.CarModifyDataArray objectAtIndex:row]objectForKey:@"mobile"];
        cell.cellLabelSix.text = [[self.CarModifyDataArray objectAtIndex:row]objectForKey:@"tel"];
        cell.cellLabelSeven.text = [[self.CarModifyDataArray objectAtIndex:row]objectForKey:@"fax"];
        cell.cellLabelEight.text = [[self.CarModifyDataArray objectAtIndex:row]objectForKey:@"address"];
        
        return cell;
    }
    if(tableView == self.queryTableView)
    {
        static NSString *indetfire = @"cell";
        QueryCustomerTableViewCell *cell = (QueryCustomerTableViewCell *)[tableView dequeueReusableCellWithIdentifier:indetfire];
        if(nil == cell)
        {
            cell = [[QueryCustomerTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indetfire];
            tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        }
        cell.queryLabelOne.text = [[self.queryDataArray objectAtIndex:row]objectForKey:@"CUSTOMER_ID"];
        cell.queryLabelTwo.text = [[self.queryDataArray objectAtIndex:row]objectForKey:@"CUSTOMER_NAME"];
        cell.queryLabelThree.text = [[self.queryDataArray objectAtIndex:row]objectForKey:@"TEL"];
        cell.queryLabelFour.text = [[self.queryDataArray objectAtIndex:row]objectForKey:@"CONTACT_MAN"];
        cell.queryLabelFive.text = [[self.queryDataArray objectAtIndex:row]objectForKey:@"MOBILE"];
//        cell.queryLabelSeven.text = [[self.queryDataArray objectAtIndex:row]objectForKey:@"fax"];
        cell.queryLabelSix.text = [[self.queryDataArray objectAtIndex:row]objectForKey:@"ADDRESS"];
        
        return cell;
    }
    return 0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(tableView == self.queryTableView)
    {
        return 45;
    }
    return 40;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell.selectionStyle = UITableViewCellSelectionStyleNone;;
    if(indexPath.row%2 == 1)
    {
        cell.backgroundColor = [[UIColor alloc]initWithRed:0.96 green:0.96 blue:0.96 alpha:1];
    }
    else
    {
        cell.backgroundColor = [[UIColor alloc]initWithRed:226.00/255 green:226.00/255 blue:226.00/255 alpha:1];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;;
}
#pragma mark - 返回按钮的回调
-(void)CarBack:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - 固定界面
-(void)loadfixedPicture
{
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [backButton setImage:[UIImage imageNamed:@"返回.png"] forState:UIControlStateNormal];
    [backButton setFrame:CGRectMake(70, 35, 45, 60)];
    [backButton addTarget:self action:@selector(CarBack:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backButton];
    
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(20, 95, 1000, 11)];
    image.image = [UIImage imageNamed:@"渐变分割线.png"];
    [self.view addSubview:image];
    UILabel *imagetitel = [[UILabel alloc]initWithFrame:CGRectMake(160, 55, 180, 35)];
    imagetitel.text = @"车辆信息编辑";
    imagetitel.backgroundColor = [UIColor clearColor];
    imagetitel.textColor = [UIColor grayColor];
    imagetitel.font = [UIFont fontWithName:@"ArialMT" size:29];
    [self.view addSubview:imagetitel];
    
//    UILabel *baoxiu = [[UILabel alloc]initWithFrame:CGRectMake(370, 325-90, 120, 30)];
//    baoxiu.backgroundColor = [UIColor clearColor];
//    baoxiu.text = @"是否保修车辆";
//    baoxiu.textColor = [UIColor grayColor];
//    baoxiu.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.backgroundView addSubview:baoxiu];
//    ,@"   生产厂家:"
    NSMutableArray *labelMutabelArray = [[NSMutableArray alloc]initWithObjects:@"     车 架 号:",@"     车 牌 号:",@"       型   号:",@"   发动机号:",@"   变速箱号:",@"       年   款:",@"     排 气 量:", nil];
//    @"变速箱类型:"
    for(int i = 0; i < 7;i++)
    {
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(15, (55+i*45), 100, 25)];
        [titlelabel setBackgroundColor:[UIColor clearColor]];
        titlelabel.text = [labelMutabelArray objectAtIndex:i];
        titlelabel.textColor = [UIColor grayColor];
        titlelabel.font = [UIFont fontWithName:@"ArialMT" size:15];
        [self.backgroundView addSubview:titlelabel];
    }
//    ,@"保修序号:",@"国家代码:"
    NSMutableArray *labelMutabelArray1 = [[NSMutableArray alloc]initWithObjects:@"内装颜色:",@"车辆颜色:",@"车  系:",@"钥  匙  号:",@"车辆用途:",nil];
    for(int i = 0; i < 5;i++)
    {
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(295, (55+i*45), 100, 25)];
        [titlelabel setBackgroundColor:[UIColor clearColor]];
        titlelabel.text = [labelMutabelArray1 objectAtIndex:i];
        titlelabel.textColor = [UIColor grayColor];
        titlelabel.font = [UIFont fontWithName:@"ArialMT" size:15];
        [self.backgroundView addSubview:titlelabel];
    }
//    self.baoXiuDaoQi = [[UILabel alloc]initWithFrame:CGRectMake(283, 372, 140, 25)];
//    [self.baoXiuDaoQi setBackgroundColor:[UIColor clearColor]];
//    self.baoXiuDaoQi.text = @"   保修月数:";
//    self.baoXiuDaoQi.textColor = [UIColor grayColor];
//    self.baoXiuDaoQi.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.backgroundView addSubview:self.baoXiuDaoQi];
    
    self.baoXiuLiChen = [[UILabel alloc]initWithFrame:CGRectMake(295, 417-44-44-44, 140, 25)];
    [self.baoXiuLiChen setBackgroundColor:[UIColor clearColor]];
    self.baoXiuLiChen.text = @"保修里程:";
    self.baoXiuLiChen.textColor = [UIColor grayColor];
    self.baoXiuLiChen.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.baoXiuLiChen setHidden:YES];
    [self.backgroundView addSubview:self.baoXiuLiChen];
    
//    UILabel *remark = [[UILabel alloc]initWithFrame:CGRectMake(15, 457, 140, 25)];
//    [remark setBackgroundColor:[UIColor clearColor]];
//    remark.text = @"   重要提示:";
//    remark.textColor = [UIColor grayColor];
//    remark.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.backgroundView addSubview:remark];
    
    UILabel *importantNotice = [[UILabel alloc]initWithFrame:CGRectMake(15, 498-41-44-44, 140, 25)];
    [importantNotice setBackgroundColor:[UIColor clearColor]];
    importantNotice.text = @"      备   注:";
    importantNotice.textColor = [UIColor grayColor];
    importantNotice.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.backgroundView addSubview:importantNotice];
    
//    @"      年检开始日期:"
    NSMutableArray *labelMutabelArray2 = [[NSMutableArray alloc]initWithObjects:@"       保  险  公  司:",@"      保险购买日期:",@"      保险到期日期:",@"       购  买  日  期:",@"       上  牌  日  期:",@"   第一次来厂日期:",@"最后一次来厂里程:", nil];
    for(int i = 0; i < 7;i++)
    {
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(550, (55+i*45), 140, 25)];
        [titlelabel setBackgroundColor:[UIColor clearColor]];
        titlelabel.text = [labelMutabelArray2 objectAtIndex:i];
        titlelabel.textColor = [UIColor grayColor];
        titlelabel.font = [UIFont fontWithName:@"ArialMT" size:15];
        [self.backgroundView addSubview:titlelabel];
    }
    NSMutableArray *labelMutabelArrayOne = [[NSMutableArray alloc]initWithObjects:@"客户",@"客户编号",@"客户名称",@"客户性质",@"手机",@"联系电话",@"联系人",@"联系地址", nil];
    for(int i = 0; i < 8;i++)
    {
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake((0+i*110), 535-44-44, 113, 40)];
        [titlelabel setBackgroundColor:[[UIColor alloc]initWithRed:240.00/255 green:240.00/255 blue:240.00/255 alpha:1]];
        titlelabel.text = [labelMutabelArrayOne objectAtIndex:i];
        [titlelabel setTextColor:[UIColor grayColor]];
        titlelabel.font = [UIFont fontWithName:@"ArialMT" size:16];
        [titlelabel setTextAlignment:NSTextAlignmentCenter];
        [self.backgroundView addSubview:titlelabel];
    }
    UIImageView *xingxingimage1 = [[UIImageView alloc]initWithFrame:CGRectMake(15, 58, 10, 10)];
    [xingxingimage1 setImage:[UIImage imageNamed:@"xingxing.png"]];
    [self.backgroundView addSubview:xingxingimage1];
//    UIImageView *xingxingimage2 = [[UIImageView alloc]initWithFrame:CGRectMake(15, 105, 10, 10)];
//    [xingxingimage2 setImage:[UIImage imageNamed:@"xingxing.png"]];
//    [self.backgroundView addSubview:xingxingimage2];
    UIImageView *xingxingimage3 = [[UIImageView alloc]initWithFrame:CGRectMake(15, 195, 10, 10)];
    [xingxingimage3 setImage:[UIImage imageNamed:@"xingxing.png"]];
    [self.backgroundView addSubview:xingxingimage3];
    UIImageView *xingxingimage4 = [[UIImageView alloc]initWithFrame:CGRectMake(15, 240, 10, 10)];
    [xingxingimage4 setImage:[UIImage imageNamed:@"xingxing.png"]];
    [self.backgroundView addSubview:xingxingimage4];
    UIImageView *xingxingimage5 = [[UIImageView alloc]initWithFrame:CGRectMake(15, 285, 10, 10)];
    UIImageView *xingxingimage8 = [[UIImageView alloc]initWithFrame:CGRectMake(15, 195-45, 10, 10)];
    [xingxingimage8 setImage:[UIImage imageNamed:@"xingxing.png"]];
    [self.backgroundView addSubview:xingxingimage8];

   
    
    [xingxingimage5 setImage:[UIImage imageNamed:@"xingxing.png"]];
    [self.backgroundView addSubview:xingxingimage5];
    UIImageView *xingxingimage6 = [[UIImageView alloc]initWithFrame:CGRectMake(565, 240-45, 10, 10)];
    [xingxingimage6 setImage:[UIImage imageNamed:@"xingxing.png"]];
    [self.backgroundView addSubview:xingxingimage6];
    UIImageView *xingxingimage7 = [[UIImageView alloc]initWithFrame:CGRectMake(550, 330-45, 10, 10)];
    [xingxingimage7 setImage:[UIImage imageNamed:@"xingxing.png"]];
    [self.backgroundView addSubview:xingxingimage7];
}

#pragma mark - 保存按钮的回调
-(void)saveButton:(id)sender
{
//   [SVProgressHUD showWithStatus:@"请等待...."];
    //拿到已编辑好数据
    self.carModifyDataDit = [[NSMutableDictionary alloc]initWithCapacity:10];
    NSMutableDictionary * carInfoDic = [[NSMutableDictionary alloc]init];
    if(self.carframe.text.length == 0)
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请输入车架号" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
    }
    else if (self.chexiBtn.titleLabel.text.length == 0){
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择车系" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
    }
    else if ([self.model.titleLabel.text isEqualToString:@""]){

        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择车型" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
    }
    else if (self.engineField.text == nil ||[self.engineField.text isEqualToString:@""]){
        
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请输入发动机号" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
//
    }
    else if (self.transmissionField.text == nil ||[self.transmissionField.text isEqualToString:@""]){
        
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请输入变速箱号" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
//
    }
    else if (self.Inparagraph.text == nil || [self.Inparagraph.text isEqualToString:@""]){
        
         UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请输入变速箱号" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
    }
    else if (self.firstTimeDate.titleLabel.text == nil || [self.firstTimeDate.titleLabel.text isEqualToString:@""]){
//
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择第一次进厂日期" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
    }
    else if(self.buyDate.titleLabel.text == nil || [self.buyDate.titleLabel.text isEqualToString:@""]){
        
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择购买日期" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
        
    }
    else if (self.KHBHLabel.text.length == 0){
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择车主" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
    
    }
    else
    {
    //车架号
    if(self.carframe.text != nil)
    {
        [self.carModifyDataDit setObject:self.carframe.text forKey:@"vin"];
         NSString *strB = [self.carframe.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"VIN"];
        
          //        新增时先查询车架号是否存在
//       if (![_CLFlag isEqualToString:@"cl"]) {
//            NSMutableDictionary * newAddDic = [[NSMutableDictionary alloc]init];
//            [newAddDic setValue:self.carframe.text forKey:@"VIN"];
//            
//            [MyAFNetWorkManager postWithParam:newAddDic andAction:@"QUERY_VEHICLE" finish:^(NSData *data, NSDictionary *obj, NSError *error) {
//                
//                if (error == nil)
//                {
//                    NSDictionary *dic = obj;
//                    NSLog(@"车辆查询 json is %@",obj);
//                    if([[dic valueForKey:@"SUCCESS"]integerValue]==1)
//                    {
//                        NSArray *array = [dic objectForKey:@"TM_VEHICLE"];
//                        if (array.count > 0) {
//                            
//                            flag = NO;
//                            
//                            UIAlertView * av = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"您输入的车架号已经存在！请重新输入" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
//                            [av show];
//                
//                        }else{
//                            flag = YES;
//                        }
//                    }
//                }
//                else{
//                    [SVProgressHUD showErrorWithStatus:error.localizedDescription];
//                }
//                
//            }];
//        }
    }
//    //生产厂家
//    if([self.manufacturer.titleLabel.text isEqualToString:@"[01] 广汽本田"])
//    {
//        [self.carModifyDataDit setObject:@"01" forKey:@"manufactureName"];
//    }
//    if([self.manufacturer.titleLabel.text isEqualToString:@"[02] 其他本田"])
//    {
//        [self.carModifyDataDit setObject:@"02" forKey:@"manufactureName"];
//    }
//    if([self.manufacturer.titleLabel.text isEqualToString:@"[03] 东风本田"])
//    {
//        [self.carModifyDataDit setObject:@"03" forKey:@"manufactureName"];
//    }
//    if([self.manufacturer.titleLabel.text isEqualToString:@"[99] 其他厂家"])
//    {
//        [self.carModifyDataDit setObject:@"99" forKey:@"manufactureName"];
//    }
    //车牌号
    if(self.licenseplate.text != nil)
    {
         NSString *strB = [self.licenseplate.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [self.carModifyDataDit setObject:self.licenseplate.text forKey:@"plateNumber"];
        [carInfoDic setObject:strB forKey:@"PLATE_NUMBER"];
    }
//        车系
if (self.chexiBtn.titleLabel.text.length !=0) {
    
    [carInfoDic setObject:self.chexiStr forKey:@"SERIES"];
        }
        
    //型号
    if(self.model.titleLabel.text != nil)
    {
        
        [self.carModifyDataDit setObject:self.carTypeId forKey:@"carType"];
        [carInfoDic setObject:self.carTypeId forKey:@"CAR_TYPE"];
    }
        
    //发动机号
    if(self.engineField.text != nil)
    {
        [self.carModifyDataDit setObject:self.engineField.text forKey:@"engineNumber"];
        
          NSString *strB = [self.engineField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"ENGINE_NUMBER"];
    }
    //变速箱号
    if(self.transmissionField.text != nil)
    {
        [self.carModifyDataDit setObject:self.transmissionField.text forKey:@"gearBoxNumber"];
         NSString *strB = [self.transmissionField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"GEAR_BOX_NUMBE"];
    }
    //年款
    if(self.Inparagraph.text != nil)
    {
        [self.carModifyDataDit setObject:self.Inparagraph.text forKey:@"year"];
         NSString *strB = [self.Inparagraph.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"YEAR"];
    }
    //排气量
    if(self.exhaust.text != nil)
    {
        [self.carModifyDataDit setObject:self.exhaust.text forKey:@"emission"];
        NSString *strB = [self.exhaust.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"EMISSION"];
    }
//    //变速箱类型
//    if(self.transmissionType.titleLabel.text != nil)
//    {
//        [self.carModifyDataDit setObject:self.transmissionType.titleLabel.text forKey:@"gearBoxType"];
//    }
    //内装颜色
    if(self.insideColor.titleLabel.text != nil)
    {
        [self.carModifyDataDit setObject:self.carInerColorId forKey:@"insideColor"];
        [carInfoDic setObject:self.carInerColorId forKey:@"INSIDE_COLOR"];
        
    }
    //车辆颜色
    if(self.carClolr.titleLabel.text != nil)
    {
        [self.carModifyDataDit setObject:self.carColorId forKey:@"carColor"];
        [carInfoDic setObject:self.carColorId forKey:@"CAR_COLOR"];
        
    }
    //钥匙号
    if(self.keyNumber.text == nil || [self.keyNumber.text isEqualToString:@""])
    {
        self.keyNumber.text = @"";
    }else{
    [self.carModifyDataDit setObject:self.keyNumber.text forKey:@"keyNumber"];
        
        NSString *strB = [self.keyNumber.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"KEY_NUMBER"];
    }
    
    //国家代码
//    if(self.countriesCodeName.titleLabel.text != nil)
//    {
//        if([self.countriesCodeName.titleLabel.text isEqualToString:@"CHN"])
//        {
//            [self.carModifyDataDit setObject:@"CHN" forKey:@"countryCode"];
//        }
//        if([self.countriesCodeName.titleLabel.text isEqualToString:@"JPN"])
//        {
//            [self.carModifyDataDit setObject:@"JPN" forKey:@"countryCode"];
//        }
//    }
    //车辆用途
    if(self.carUse.titleLabel.text != nil)
    {
        [carInfoDic setObject:self.CarUseID forKey:@"CAR_USE"];
//        if([self.carUse.titleLabel.text isEqualToString:@"上下班"])
//        {
//            [self.carModifyDataDit setObject:@"1" forKey:@"carUse"];
//        }
//        if([self.carUse.titleLabel.text isEqualToString:@"公事"])
//        {
//            [self.carModifyDataDit setObject:@"2" forKey:@"carUse"];
//        }
//        if([self.carUse.titleLabel.text isEqualToString:@"休闲"])
//        {
//            [self.carModifyDataDit setObject:@"3" forKey:@"carUse"];
//        }
//        if([self.carUse.titleLabel.text isEqualToString:@"其他"])
//        {
//            [self.carModifyDataDit setObject:@"0" forKey:@"carUse"];
//        }
    }
//    //保修序号
//    if(self.warrantyNumber.text == nil || [self.warrantyNumber.text isEqualToString:@""])
//    {
//        self.warrantyNumber.text = @"";
//    }else{
//    [self.carModifyDataDit setObject:self.warrantyNumber.text forKey:@"WarrantyNumber"];
//    }
//    
//    //保修月数
//    if(self.monthsOfNumber.text == nil || [self.monthsOfNumber.text isEqualToString:@""])
//    {
//        self.monthsOfNumber.text = @"";
//    }
//    [self.carModifyDataDit setObject:self.monthsOfNumber.text forKey:@"WarrantyMonths"];
//    //保修里程
//    if(self.liChenShuRu.text == nil || [self.liChenShuRu.text isEqualToString:@""])
//    {
//        self.liChenShuRu.text = @"";
//    }
//    [self.carModifyDataDit setObject:self.liChenShuRu.text forKey:@"WarrantyMileage"];
    //保险公司
    if(self.baoxiangongsiBtn.titleLabel.text == nil || [self.baoxiangongsiBtn.titleLabel.text isEqualToString:@""])
    {
        self.baoxiangongsiBtn.titleLabel.text = @"";
    }else{
        [self.carModifyDataDit setObject:self.baoxiangongsiBtn.titleLabel.text forKey:@"insuranceCompany"];
        
        [carInfoDic setObject:self.baoxiangongsiID forKey:@"INSURANCE_COMPANY"];
    }
   
    //保险购买日期
    if(self.baoxiangoumaiBtn.titleLabel.text == nil || [self.baoxiangoumaiBtn.titleLabel.text isEqualToString:@""])
    {
        self.baoxiangoumaiBtn.titleLabel.text = @"";
    }
    else{
    [self.carModifyDataDit setObject:self.baoxiangoumaiBtn.titleLabel.text forKey:@"insuranceBuyDate"];
        NSString *strB = [self.baoxiangoumaiBtn.titleLabel.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"INSURANCE_BUY_DATE"];
    }
    
    //保险到期日期
    if(self.baoxiandaoqiBtn.titleLabel.text == nil || [self.baoxiandaoqiBtn.titleLabel.text isEqualToString:@""])
    {
        self.baoxiandaoqiBtn.titleLabel.text = @"";
    }else{
    [self.carModifyDataDit setObject:self.baoxiandaoqiBtn.titleLabel.text forKey:@"insuranceExpiresDate"];
        NSString *strB = [self.baoxiandaoqiBtn.titleLabel.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"INSURANCE_EXPIRES_DATE"];
    }
    
//    //年检开始日期
//    if(self.checkStartDate.titleLabel.text == nil || [self.checkStartDate.titleLabel.text isEqualToString:@""])
//    {
//        self.checkStartDate.titleLabel.text = @"";
//    }
//    [self.carModifyDataDit setObject:self.checkStartDate.titleLabel.text forKey:@"yearCheckStartDate"];
    //购买日期
    if(self.buyDate.titleLabel.text == nil || [self.buyDate.titleLabel.text isEqualToString:@""])
    {
        self.buyDate.titleLabel.text = @"";
    }else{
    [self.carModifyDataDit setObject:self.buyDate.titleLabel.text forKey:@"buyDate"];
         NSString *strB = [self.buyDate.titleLabel.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"BUY_DATE"];
    }
    
    //上牌日期
    if(self.registrationDate.titleLabel.text == nil || [self.registrationDate.titleLabel.text isEqualToString:@""])
    {
        self.registrationDate.titleLabel.text = @"";
    }else{
    [self.carModifyDataDit setObject:self.registrationDate.titleLabel.text forKey:@"plateDate"];
        NSString *strB = [self.registrationDate.titleLabel.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"PLATE_DATE"];
    }
    
    //第一次来厂日期
    if(self.firstTimeDate.titleLabel.text == nil || [self.firstTimeDate.titleLabel.text isEqualToString:@""])
    {
        self.firstTimeDate.titleLabel.text = @"";
    }else{
    [self.carModifyDataDit setObject:self.firstTimeDate.titleLabel.text forKey:@"firstComingDate"];
        
        NSString *strB = [self.firstTimeDate.titleLabel.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"FIRST_COMING_DATE"];
    }
    
    //最后一次来厂里程
    if(self.lastComingMileage.text == nil || [self.lastComingMileage.text isEqualToString:@""])
    {
        self.lastComingMileage.text = @"";
    }else{
    [self.carModifyDataDit setObject:self.lastComingMileage.text forKey:@"lastComingMileage"];
        NSString *strB = [self.lastComingMileage.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"LAST_COMING_MILEAGE"];
    }
    
//    //重要提示
//    if(self.importantNotice.text == nil || [self.importantNotice.text isEqualToString:@""])
//    {
//        self.importantNotice.text = @"";
//    }
//    [self.carModifyDataDit setObject:self.importantNotice.text forKey:@"importantNotice"];
    //备注
    if(self.remark.text == nil || [self.remark.text isEqualToString:@""])
    {
        self.remark.text = @"";
    }else{
    [self.carModifyDataDit setObject:self.remark.text forKey:@"remark"];
        NSString *strB = [self.remark.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [carInfoDic setObject:strB forKey:@"REMARK"];
    }
        if (self.KHBHLabel.text.length != 0) {
             [carInfoDic setObject:self.KHBHLabel.text forKey:@"OWNER_NO"];
        }
   
      
        
        if ([_CLFlag isEqualToString:@"cl"]) {
              [carInfoDic setObject:@"U" forKey:@"STATUS"];
        }else{
         [carInfoDic setObject:@"A" forKey:@"STATUS"];
            
     
            
           
        }
  
    //车主，使用者，驾驶员
//    [self.carModifyDataDit setObject:self.CarModifyDataArray forKey:@"customerList"];
//    webService *web = [[webService alloc]init];
//    web.methodName = CREATEREPAIRCAR;
//    [web commonPostSharedRequest:CREATEREPAIRCAR psotDic:self.carModifyDataDit];
    NSLog(@"上传字典---%@",carInfoDic);
        
        
//        NSLog(@"flag--------  %d",flag);
   
//        if (flag == YES || (flag == NO &&  [_CLFlag isEqualToString:@"cl"])) {
//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                //api调用及返回
                [MyAFNetWorkManager postWithParam:carInfoDic andAction:@"MAINTAIN_VEHICLE_FOR_PAD" finish:^(NSData *data, NSDictionary *obj, NSError *error) {
                    [SVProgressHUD dismiss];
                    if (error == nil)
                    {
                        NSLog(@"车辆新增 json is %@",obj);
                        if ([obj[@"SUCCESS"] integerValue] == 1) {
                            
                            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"车辆信息添加成功！" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                            [alertView show];
                            
                            [self.navigationController popToRootViewControllerAnimated:YES];
//                            self.saveButton.userInteractionEnabled = NO;
//                            self.saveButton.alpha = 0.4;
                        }
                        else if([obj[@"SUCCESS"] integerValue] == 0 && [obj[@"MSG"] isEqualToString:@"该车架号已经存在！"]){
                        
                            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"该车架号已经存在！请重新输入" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                            [alertView show];
                        }
                    }
                    else{
                        [SVProgressHUD showErrorWithStatus:error.localizedDescription];
                    }
                    
                }];
    
//            });
//        }else{
//            UIAlertView * av = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"您输入的车架号已经存在！请重新输入" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
//            [av show];
//        }
        
   
   }
}
-(void)createRepairCar:(NSNotification*)notification
{
    NSMutableDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData *)notification.object options:NSJSONReadingMutableLeaves error:nil];
    if([theJson valueForKey:@"error_code"])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[theJson valueForKey:@"error_msg"] message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"新增成功！" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alertView show];
    }
}
#pragma mark  --tableView上的button点击回调方法

////弹出回调方法
-(void)selectDelegate:(NSInteger)row btn:(UIButton *)btn
{
    NSLog(@"selectDelegate");
    if(btn == self.insideColor)
    {
        self.carInerColorId = [self.carInerColorArray objectAtIndex:row];
        NSLog(@"%@---",self.carInerColorId);
    }
    if(btn == self.carClolr)
    {
        
        self.carColorId = [self.carColorArray objectAtIndex:row];
        NSLog(@"%@---",self.carColorId);
//        self.carColorId = [[self.carColorArray objectAtIndex:row]objectForKey:@"COLOR_CODE"];
     
    }
    if (btn == self.chexiBtn) {
        self.chexiStr = [self.chexiArr objectAtIndex:row];
    }
    if(btn == self.model)
    {
        self.carTypeId = [self.carTypeArray objectAtIndex:row];
        NSLog(@"%@---",self.carTypeId);
    }
    if (btn == self.baoxiangongsiBtn) {
        self.baoxiangongsiID = [self.baoxiangongsiArray objectAtIndex:row];
        NSLog(@"%@---",self.baoxiangongsiID);
    }
    if (btn ==self.carUse) {
        self.CarUseID = [self.carUseArray objectAtIndex:row];
        NSLog(@"%@--",self.CarUseID);
    }
    
    [self.popCon dismissPopoverAnimated:YES];
    self.popCon = nil;
}
-(void)textFieldDidBeginEditing:(UITextField *)textField     //弹出键盘的时候上提
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.4];
    [self.view setFrame:CGRectMake(0, 0-180, 1024, 768)];
    [UIView commitAnimations];
}
- (void)keyboardHide:(NSNotification *)notif   //键盘即将消失的时候点done归为view
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    [self.view setFrame:CGRectMake(0, 0, 1024, 768)];
    [UIView commitAnimations];
}
-(void)addNotification
{
    //获取车型列表
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCarType:) name:GETCARTYPENAMELIST object:nil];
    //获取内饰颜色列表
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCarInnerColorList:) name:GETCARINNERCOLORLIST object:nil];
    //获取车辆颜色列表
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getcarColorList:) name:GETCARCOLORLIST object:nil];
    //车辆信息新增
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(createRepairCar:) name:CREATEREPAIRCAR object:nil];
    //多客户分配
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(searchCustomerList:) name:SEARCHCUSTOMERLIST object:nil];
    //生产厂家列表
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getManufactureList:) name:GETMANUFACTURELIST object:nil];
}
-(void)removeNotification
{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end